Styled Fractions in Windows

Summary
While some fractions are automatically available, we can also 'create' less-commonly used fractions by using Windows Character Map, Utility, Microsoft Word's Symbol Library, or Microsoft Office's Auto-Correct capability.
Details
Some fractions are available as ASCII characters (¼, ½ and ¾) and a limited number of others are available within Unicode's extended character set (⅓, ⅔, ⅛, ⅜, ⅝ and ⅞). When it becomes necessary to produce less common fractions that are not so readily available, Unicode characters give us that ability by constructing the fraction's numerator and denominator with superscripts and subscripts.

The numerators start wth ASCII code ¹ (0×185), ² (0×178) and ³ (0×179). After that, Unicode characters for ⁴ to ⁹ (H2074 to H2079) and ⁰ (H2070) should be put to use. The denominators can be generated with the Unicode characters ₀ to ₉ (H2080 to H2089). While a standard forward slash may be sufficient, I prefer the Unicode Fraction Slash (⁄ or H2044). This article will demonstrate a universal method for all Windows programs, an MS Word specific method using the Symbol library and the use of MS Office’s AutoCorrect Proofing tool to replace typed fractions with styled replacements.

 

A.   Windows’ Character Map Utility

  • Open the Character Map utility found in All Programs Accessories System Tools.
  • Build your fraction by choosing each superscript or subscript digit and clicking Select.
  • When the fraction is complete click Copy, then move to your target Office application and paste the completed fraction into your document.

               

 

 B.   Word’s Symbol Library

  • MS Word’s Symbol library (Insert Symbol More Symbols) holds all of the ASCII and Unicode characters for creating your own fractions on-
    the-fly.

                   

 

  • The image above shows the location of the denominators, the fraction slash and most numerators. The ¹, ² and ³ numerators are located much closer to the top of the symbol library.

 

C.    MS Office’s AutoCorrect

  •  While the capability is there to produce stylized number display for virtually any fraction, generating more than a few of these quickly becomes tedious and a lengthy document which includes many variations will become unwieldy. Office's AutoCorrect functionality can reduce this to simply typing the digits required but even this becomes a chore after entering more than a few fraction Replace: and With: values into the Proofing tools' AutoCorrect Replace as you type.

    I've written the following macro to quickly populate Office Proofing AutoCorrect Replace as you type entries with all of the fractions for any given denominator. Office's Proofing, AutoCorrect entries are common to all Office applications so that entry into one application (such as Excel) will have the same entry available in other Office applications with Proofing tools (such as Word). Due to subtle differences in the way Word VBA and Excel VBA handle things like the Application.InputBox command, I've chosen Excel as the preferred method of distribution. There is a sample macro-enabled workbook available through a download link toward the end of this article but you can also paste the following into Excel's Visual Basic Editor by tapping Alt+F11. Once the VBE opens, use the pull-down menus to Insert Module and paste this code into the new pane titled something like Book1 -Module1 (Code).

    Sub mcr_Fractional_AutoCorrect_Entries_Add()
        Dim i As Integer, l As Integer, n As Integer, d As Integer
        Dim iNumer As Integer, iDenom As Integer, sOrig As String
        Dim s As String, sNumer As String, sDenom As String
       
        iDenom = Abs(Application.InputBox(prompt:="Please supply a “ & _
          denomonator to create fractions for:", _
          Title:="Denomonator for AutoCorrect Fractions", Type:=1))
       
        If CBool(iDenom) Then
            On Error Resume Next
            For i = 0 To iDenom
                n = i
                d = iDenom
                If n > 1 And n < d Then
                    For l = (d / 2) To 2 Step -1
                        If Not CBool(n Mod l) And Not CBool(d Mod l) Then
                            n = n / l
                            d = d / l
                            Exit For
                        End If
                    Next l
                End If
                sOrig = n & Chr(47) & d
                sNumer = vbNullString
                For l = 1 To Len(Format(n, "0"))
                    s = Mid(Format(n, "0"), l, 1)
                    Select Case s
                        Case 1
                            sNumer = sNumer & Chr(185)
                        Case 2, 3
                            sNumer = sNumer & Chr(176 + Int(s))
                        Case 0, 4, 5, 6, 7, 8, 9
                            sNumer = sNumer & ChrW(&H2070 + Int(s))
                    End Select
                Next l
                sDenom = vbNullString
                For l = 1 To Len(Format(d, "0"))
                    s = Mid(Format(d, "0"), l, 1)
                    sDenom = sDenom & ChrW(&H2080 + Int(s))
                Next l
                Application.AutoCorrect.DeleteReplacement What:=sOrig
                Application.AutoCorrect.AddReplacement sOrig, _
                  sNumer & ChrW(&H2044) & sDenom
            Next i
        End If
    End Sub
  • Tap Alt+Q to return to your worksheet when you have that pasted, then Alt+F8 to open the Macros dialog and Run the macro.

                        

    Supply a number for the fraction’s denominator and click OK. The corrected fractions and their original typed entries will be listed in the active worksheet starting at J2.
  • Once the macro has completed, typing your fraction will result in its automatic conversion. Any AutoCorrection can be reversed to its originally typed value by tapping Ctrl+Z (Undo) immediately after the correction has been made.
    If for any reason you wish to remove the fraction AutoCorrect entries, there is a remove macro supplied with the sample workbook as well.

 

There are a few points to make about the fractions and the macro.

·         These stylized fractions are for labeling purposes. They cannot be used in calculations.

·         Each fraction created is resolved down to its lowest denominator. For example: ²⁴⁄₆₀  is created as ²⁄₅.

·         While these entries will be available to any Office application with Proofing tools, each Office application reads its Proofing tools into memory

          the first time it is used. In other words, if Publisher has already been used at least once in the current computer session, the computer will have

          to be restarted before the new AutoCorrect entries are available to Publisher.

 

 

 

 

 

Forum Article Info


Last updated December 8, 2019 Views 5,674 Applies to:

Awesome!  Wish I had this back when I was working at the UW and writing scientific papers!

 

Thank you Jeeped for your wiki post - I did not know about these techniques to get to the less common fractions.

 

In case anyone wanted to know, in addition to the ways that jeeped has mentioned in his wiki post, here is another way to organize the various Unicode symbols that could be used for fractions.  Below are two screen prints from Excel 2013, using the UNICHAR function (as I recall, available in only Excel 2013, and the Excel Web App, but not in versions of Excel prior to Excel 2013).  If need be, the Unicode symbols can be copied from this Excel file, into Word, for example.

 

Excel with formulas off:

 

 

Excel with formulas on (within Options, I checked the box for "Show formulas in cells instead of their calculated results)":

 

 

The above mentioned Excel file also features a side-by-side conversion of the decimal to hex.  The above technique could be used not just for fractions, but also for ANY Unicode symbols (just number the decimal column from 1 to 65533).  However, Excel installed on a PC can handle all 65533 codes in a single Excel file (if your PC if fast enough), but in my tests the Excel Web App locks up, when I tried to open a file that had ALL of the 65533 Unicode characters.  Thus for the Excel Web App, you might try a small subset, of perhaps 50 or so Unicode characters for each file.  I thought the above Excel information might be of interest to someone, so I added it to this wiki page.  In case anyone does not already know this, the free Excel Web App can be found at this link:

 

https://skydrive.live.com/

PS - Below is a screen-print of the Chess Piece symbols, using the formulas shown above, within the Excel Web App:

 

Good tip Anthony.

I did a simple paste of the 2013 spreadsheet into Word 2010. The new functions were pasted as values, but that is OK because the conversions had already been done.  So now I can change the font in Word and see how the characters display.

What I'm looking for is a way of identifying the various new Open Type attributes:
  • Ligatures: standard, Standard & Contextual, Historical & Discretionary
  • Number Spacing: Proportional, Tabular
  • Number Forms: Lining, Old style
  • Stylistic Sets: 1-20

What I've been looking for is an utility that would display this formatting for me, but haven't seen one yet.


Any chance you would be willing to post that spreadsheet you created.  Recreating it is easy enough, just time consuming.


◕_◕
.
I was reading a book on helium.
I couldn’t put it down.

Thank you for taking the time to create this article it is very helpful.

Ali Sajadi
System Architects Inc.