Previous 1 2 Next 16 Replies Latest reply: Jul 23, 2008 10:22 AM by Hiroto
Anthony Jackson3 Level 1 Level 1 (5 points)
I've some mediaeval RTF study documents which include fractions. They display fine in TextEdit (but other aspects of the formatting do not) but I can find no way to get them to display in AppleWorks 6.2.9.

I can open Character Palette in TextEdit, and select fractions (and all sorts of other things). I can drag e.g. ½ from Character Palette to here. But not in AppleWorks? I appear to have three copies of many fonts. I wonder whether removing all but the one which has these extra features would force AppleWorks to use it, but I'm not sure how to go about this (or indeed whether it is a good idea!) If I copy and paste from TextEdit to AppleWorks the fractions turn into question marks? I can copy into Word, but...

Mac Mini G4 1.5 GHz, Mac OS X (10.4.11)
  • Peggy Level 8 Level 8 (38,525 points)
    AppleWorks 6 is an OS 8/9 program carbonized to run in OS X. AppleWorks cannot use most of the available Characters in Character Palette & will crash if you use a Unicode keyboard layout. You need to use Keyboard Viewer with AppleWorks.

    That being said, the way to get the fractions to look similar in AppleWorks is to use superscript & subscript & a smaller font size. T & B has an Enhancement Pack for AppleWorks that has an AppleScript to do this.

  • Brie Fly Level 5 Level 5 (7,925 points)
    That being said, the way to get the fractions to look similar in AppleWorks is to use superscript & subscript


    ... or use the built-in equation editor.
  • Anthony Jackson3 Level 1 Level 1 (5 points)
    Thanks for this, Peggy.

    I found and opened Keyboard Viewer, but it takes me to the Character Palette window, to which AppleWorks is blind, sadly.

    I've made up my own fractions from superscript/subscript, but that messes up the line spacing. Maybe I need to save up for a copy of iWork (except it doesn't include the draw facility, which I sometimes use, and which can see Claris CAD files (which I also use).

    The ehancementpack looks a lot to pay for just the one 5 year-old thing, but maybe I should check it out.

    Thanks, T.
  • Anthony Jackson3 Level 1 Level 1 (5 points)
    Thanks for this thought! But...

    The Equation Editor doesn't seem to offer a way to write 'half' with an oblique between the '1' and the '2'?

    Best regards, T.
  • Barry Level 7 Level 7 (29,210 points)
    "The Equation Editor doesn't seem to offer a way to write 'half' with an oblique between the '1' and the '2'?"

    So use the method suggested earlier:

    Type (in this case a mixed fraction) 4 2/3 ,setting fomatting for each character in the fraction as you go. The series of keystrokes to use is as below. Items enclosed in parentheses are keystroke combinations, explained below.

    4(space)(shift-command-)2(command-T)(shift-option-1)(shift+command-)3(command-T)(space)


    • 4, 2, 3 are the individual digits in the mixed fraction.
    • space is a space character.
    • shift-command-+ means press and hold the shift and command keys then tap and release the + key, then relese the shift and command keys. This keystroke combination sets Text Style to Superscript.
    • command-T sets Text Style to Plain Text
    • shift-option-1 is a "special character", an oblique stroke that is a zero width character. Using it tightens the fraction horizontally compared to using the oblique stroke on the "?" key.
    • shiftcommand- sets Text Style to Subscript (the "+" means the same as the "-" in the other keystroke combinations and is used in this instruction as "-" is the action key)
    • command-T sets Text Style back to Plain Text.

    When done, you might want to select and decrease the font size of the two numerals in the fraction part. I usually find the reduction built into Superscript and Subscript settings leaves them to big.

    Because you'll be using fractions on a regular basis, I'd suggest setting up a "clip sheet"—a WP document with a collection of your most frequently used fractions in the fonts and sizes you use most often—then copy the fraction (and the Plain Text space character before and after it) to paste into a document where you need the fraction.

    Fractions not in your collection can be constructed using the method above, or by modifying fractions you have already constructed. When modifying, remember to type the new numeral after the original, then delete the original. Deleting the original first will also delete its Style setting.

    eg. to change 1/2 to 3/4
    First add the NEW numerals after the originals: 13/24
    Then delete the originals: 3/4

    The alternate, of course is to switch to a word processor that can accept Unicode encoded text.

    Regards,
    Barry
  • Brie Fly Level 5 Level 5 (7,925 points)
    The Equation Editor doesn't seem to offer a way to write 'half' with an oblique between the '1' and the '2'?


    My math students would beg to differ with you on this. Equation editor is employed in the production of all their worksheets and exams, and all their supplemental handouts
  • Hiroto Level 5 Level 5 (5,620 points)
    Hello

    Also you may use the following scripts of mine freely.
    There're two versions.
    One is for inserting new fraction into the location of current selection. Another is for formatting existing fraction in current selection.

    Both will yield fraction in style as superior / inferior, where / is FRACTION SLASH. (U+2044 which is 0xDA = 218 in MacRoman) And both can process selection in text body of WP doc and in text frame of WP and DR doc.

    Tested with AW6.2.3 under OS9.1.
    Hope this may be some help,
    H



    --SCRIPT1
    (*
      fraction - insert
      v0.2
      
      Preparation -
        Copy this script into new window of Script Editor and
        save it as application (without showing startup screen) in, e.g. -
          AppleWorks 6:AppleWorks Essentials:Scripts:WP:
        and restart AppleWorks 6. Then you can call it from AppleWorks 6's Scripts menu.

      Usage -
        Select target text range or insertion point where to insert fraction and then call this script.
        It will ask you fraction and put it in current selection with fraction's style, i.e.,
         superior / inferior, where / is (equivallent to) U+2044 FRACTION SLASH
    *)
    main()
    on main()
    script o
    property SOLIDUS : "/" as Unicode text -- U+002F
    property FRACTION_SLASH : «data utxt2044» as anything -- U+2044

    -- accept fraction text
    repeat
    display dialog "Enter fraction." default answer "p/q" with icon 1
    set t to text returned of result
    try
    set k to offset of SOLIDUS in t
    set k1 to offset of FRACTION_SLASH in t
    if k = 0 or (k > k1 and k1 > 0) then set k to k1
    if k = 0 then error number 8000
    set n to t's text 1 thru (k - 1)
    set d to t's text (k + 1) thru -1
    exit repeat
    on error --
    display dialog "Invalid fraction: " & t with icon 2
    end try
    end repeat
    set frac to (n & FRACTION_SLASH & d) as Unicode text

    -- insert fraction text in current selection and set its style
    tell application "AppleWorks 6"
    activate
    set selection to frac
    tell (get object specifier of selection)
    tell text 1 thru (k - 1) -- numerator
    set style to {on styles:{superior}}
    end tell
    tell text k thru k -- fraction slash
    set style to {on styles:{plain}}
    end tell
    tell text (k + 1) thru -1 -- denominator
    set style to {on styles:{inferior}}
    end tell
    end tell
    end tell
    end script
    tell o to run
    end main
    --END OF SCRIPT1



    --SCRIPT2
    (*
      fraction - format
      v0.2

      Preparation -
        Copy this script into new window of Script Editor and
        save it as application (without showing startup screen) in, e.g. -
          AppleWorks 6:AppleWorks Essentials:Scripts:WP:
        and restart AppleWorks 6. Then you can call it from AppleWorks 6's Scripts menu.

      Usage -
        Select fraction text (e.g. '1/2') and call this script.
        It will change its style to fraction's style, i.e.,
         superior / inferior, where / is (equivallent to) U+2044 FRACTION SLASH
    *)
    main()
    on main()
    script o
    property SOLIDUS : "/" as Unicode text -- U+002F
    property FRACTION_SLASH : «data utxt2044» as anything -- U+2044

    -- get and analyse text of selection
    tell application "AppleWorks 6"
    set t to text of selection
    end tell
    set k to offset of SOLIDUS in t
    set k1 to offset of FRACTION_SLASH in t
    if k = 0 or (k > k1 and k1 > 0) then set k to k1
    if 2 > k or k = (count t) then
    display dialog "No fraction is selected." with icon 2
    error number -128
    end if

    -- set fraction's style of current selection
    tell application "AppleWorks 6"
    activate
    tell (get object specifier of selection)
    tell text 1 thru (k - 1) -- numerator
    set style to {on styles:{superior}}
    end tell
    tell text k thru k -- fraction slash
    set its text to FRACTION_SLASH
    set style to {on styles:{plain}}
    end tell
    tell text (k + 1) thru -1 -- denominator
    set style to {on styles:{inferior}}
    end tell
    end tell
    end tell
    end script
    tell o to run
    end main
    --END OF SCRIPT2
  • Level 8 Level 8 (41,780 points)
    Hello Hiroto

    Why are you using
    property FRACTION_SLASH : «data utxt2044» as anything -- U+2044

    For years I uses the same kind of script with:

    property FRACTION_SLASH : ASCII character (218)

    I get exactly the same result.

    Is the format utxt more robust given localisation problems ?

    Yvan KOENIG (from FRANCE vendredi 18 juillet 2008 16:30:56)
  • Hiroto Level 5 Level 5 (5,620 points)
    Good evening Yvan,

    Well, there's not that much reason for it.

    I do not think 'ASCII character 218' will break in the foreseeable future, even though they say 'ASCII character' is deprecated as of AppleScript 2.0. So I may use 'ASCII character 218' as well.

    Yet I used '«data utxt2044» as anything' because a) I have complete Unicode character table (pdf) at hand and it's been my late practice to find character in it; and b) I somewhat think it can be a better alternative to 'character id 8260' which is recommended in AppleScript 2.0. (I said 'better' (for me) because I can use 2044 of U+2044 FRACTION SLASH directly instead of calculating its decimal value 8260. I'm a lazy person, as you might know. )

    By the way, '«data utxt2044» as Unicode text' won't work with AS1.8.3 under OS9.1. I have to say '«data utxt2044» as anything' instead. The 'as anything' coercion is a convenient way to get AppleScript value from well-formed data literal.

    All the best,
    Hiroto
  • Level 8 Level 8 (41,780 points)
    Hello

    two lazy guys heavily working aren't we ?

    Yvan KOENIG (from FRANCE vendredi 18 juillet 2008 18:54:56)
  • Anthony Jackson3 Level 1 Level 1 (5 points)
    I guess Brie Fly's maths students have a different Equation Editor - mine will permit me to type an oblique, and to set the lower digit to subscript, but not the upper figure to superscript - and if it did it wouldn't be doing anything I can't do in Text>Style in AppleWorks proper. Alright, I guess they are cleverer than me!

    I tried the AppleScript: I've never before composed an AppleScript, so this was something new.

    It seemed not to work until I removed the first line ('*)')

    Then it worked, but only if I called it via 'Show Scripts' in the Scripts menu. If I scrolled down to Word Processing under Scripts it was there, but unlike the others listed it had a suffix .scpt, and clicking on it got me "An unexpected error occurred. [hash]32" Then I re-read the bit about 'save it as an application... Like I wrote, I'd not done this before! (But all the other scripts in the WP folder call themselves scripts, and work just fine?)

    Barry's method got me a better-looking 1/2 (which looks like this 1⁄2 when I copy and paste it here).

    Of course, by these means I can get a 'half' written, and then use it to replace every occurrence of a '?' in my imported document. But then I need to go through the document against its version displayed in TextEdit to correct whichever may be the '?'s which were shown in response to 1/4 or 3/4, not 1/2. In a big document not an appealing prospect.

    Am I right to believe that while I can produce a decent-looking half to display in an AppleWorks document, there is no way to get AppleWorks to 'see' fractions in a PC-generated text document and display them correctly in the way that TextEdit does? So the question then becomes whether to learn NeoOffice or iWork?

    Best, T.
  • Level 8 Level 8 (41,780 points)
    Am I right to believe that while I can produce a decent-looking half to display in an AppleWorks document, there is no way to get AppleWorks to 'see' fractions in a PC-generated text document and display them correctly in the way that TextEdit does?


    You are right AppleWorks is unable to recognize them.

    About the script question, we must use script saved as application because the Script Editor delivered with Mac OS X creates xx.scpt files whose structure is not the same as the old fashioned ones.
    In old ones the useful code was in a resourceFork and AppleWorks know the way to read this fork.

    With the "notsorecent" editor the useful code is in the datafork and AppleWorks is unable to use it.
    This is why we must save the scripts as Applications which AppleWorks may use.
    If for some reason you must edit an old script, you will be forced to save it as an application to be able to use it.

    Yvan KOENIG (from FRANCE samedi 19 juillet 2008 19:20:41)
  • Hiroto Level 5 Level 5 (5,620 points)
    Hello

    You may edit the rtf files directly by plain text editor before opening it as rtf by TextEdit.
    Most popular single-character fractions' code points are as follows.

    Unicode:
    U+00BC = 1/4
    U+00BD = 1/2
    U+00BE = 3/4

    ISO-8859-1:
    BC = 1/4
    BD = 1/2
    BE = 3/4

    Therefore, edit the rtf contents as follows.
    (X => Y denotes to replace X with Y)

    \'bc => 1/4
    \'bd => 1/2
    \'be => 3/4

    OR:

    \'bc => {\up 1}\u8260/{\dn 4}
    \'bd => {\up 1}\u8260/{\dn 2}
    \'be => {\up 3}\u8260/{\dn 4}

    ('bc', 'bd' and 'de' are all preceded by a backslash followed by an apostrophe. The latter replacements will hopefully generate 'superscript/subscript' output, where '/' is FRACTION SLASH. In my brief test, it does generate 'superscript/subscript' output, but not sure whether it will work for you as well.)

    This way single-character fraction will be replaced by three-character version and at least you won't be troubled by '?' in lieu of real data.

    ---
    By the way, there're more fraction characters defined in the Unicode standard. E.g. -

    U+2153 = 1/3
    U+2154 = 2/3
    U+2155 = 1/5
    U+2156 = 2/5
    U+2157 = 3/5
    U+2158 = 4/5
    U+2159 = 1/6
    U+215A = 5/6
    U+215B = 1/8
    U+215C = 3/8
    U+215D = 5/8
    U+215E = 7/8
    U+215F = 1/ (FRACTION NUMERATOR ONE)

    If some of these are also used in the text, you'd need to replace every corresponding rtf representation with its thee-character version (i.e. 'compatibility decomposition' in Unicode term). I don't know how exactly they're represented in rtf. You'll have to investigate the real rtf file if need be.

    The rest is my wild guess. Possibly like these (?)
    (X = Y denotes that single-character fraction X is represented as Y in rtf)

    1/3 = {\uc3\u8531 1/3}
    2/3 = {\uc3\u8532 2/3}
    1/5 = {\uc3\u8533 1/5}
    2/5 = {\uc3\u8534 2/5}
    3/5 = {\uc3\u8535 3/5}
    4/5 = {\uc3\u8536 4/5}
    1/6 = {\uc3\u8537 1/6}
    5/6 = {\uc3\u8538 5/6}
    1/8 = {\uc3\u8539 1/8}
    3/8 = {\uc3\u8540 3/8}
    5/8 = {\uc3\u8541 5/8}
    7/8 = {\uc3\u8542 7/8}
    1/ = {\uc2\u8543 1/}

    If so, replace them as follows:
    (X => Y denotes to replace X with Y)

    \uc3\u8531 1/3 => {\up 1}\u8260/{\dn 3}
    \uc3\u8532 2/3 => {\up 2}\u8260/{\dn 3}
    \uc3\u8533 1/5 => {\up 1}\u8260/{\dn 5}
    \uc3\u8534 2/5 => {\up 2}\u8260/{\dn 5}
    \uc3\u8535 3/5 => {\up 3}\u8260/{\dn 5}
    \uc3\u8536 4/5 => {\up 4}\u8260/{\dn 5}
    \uc3\u8537 1/6 => {\up 1}\u8260/{\dn 6}
    \uc3\u8538 5/6 => {\up 5}\u8260/{\dn 6}
    \uc3\u8539 1/8 => {\up 1}\u8260/{\dn 8}
    \uc3\u8540 3/8 => {\up 3}\u8260/{\dn 8}
    \uc3\u8541 5/8 => {\up 5}\u8260/{\dn 8}
    \uc3\u8542 7/8 => {\up 7}\u8260/{\dn 8}
    \uc2\u8543 1/ => {\up 1}\u8260/

    Good luck,
    H

    PS. If the method explained above turns out to yield acceptable result, it's not too difficult to write a script to edit multiple rtf files as such.

    Message was edited by: Hiroto (fixed typo)
  • Anthony Jackson3 Level 1 Level 1 (5 points)
    Hi Yvan,

    Thanks for explaining about the AppleScript - I'd otherwise have spent a while fretting over it!
Previous 1 2 Next