# Writer: How to align a fraction with text

I am trying to create a document that has whole numbers and fractions within it. I have found that I need to insert a formula to create the fraction. I can adjust the size of the font in the fraction so that it near enough matches the size of the whole number next to it. update of question. OK I have removed all of LO and then reinstalled just 5.4. That went well, I then added the Verajja font. If I add the ':afrc' to the end of the font name I still do not get any fractions as I would like them. I am using Verajja Serif 18pt. I even tried creating a style called fractions and set the font there to Verajja Serif:afrc, still with no response. When typing is the fraction supposed to auto adjust or do I have to select it and then do something else?

edit retag close merge delete

Sort by » oldest newest most voted

## OpenType - Fractions

(a.k.a. slashed fractions)

The OpenType Fractions feature will do what you need.
In LibreOffice you simply add :frac to the font name.
For example you highlight the fraction text such as 17/64
and then select the font for that text such as Source Sans Pro:frac

Here is an example:

The first line is the plain text.
The second and third lines have the fraction feature applied.

You must use a font which supports this OpenType feature.
Fonts which come with LibreOffice which support Fractions OpenType feature:
- Carlito
- Linux Biolinum G
- Linux Libertine Display G
- Linux Libertine G
- PT Serif
- Source Code Pro (all variants)
- Source Sans Pro (all variants)

My guess is that one of the bolder Source Sans Pro fonts will be best for your project.

Make yourself a character style called Fractions, set the font to Source Sans Pro Bold:frac
Then just apply that character style to the fraction numbers.

## OpenType - Alternative Fractions

(a.k.a. stacked fractions or nut fractions)

Applied by adding :afrc to font name.
Again, the font must support the feature.

None of the fonts included with LibreOffice support OpenType Alternative Fractions.
The Palatino Linotype font included with Windows 7 does have limited support (only up to 7/8).
The Linux Libertine G font does support Graphite alternative fractions, but they are bad.
Take a look the image below for examples.

There are a number of commercial fonts which do support OpenType Alternative Fractions.
You can find those on the font purchasing websites.

I did find some free fonts which support OpenType Alternative Fractions.
- Guru (a condensed Garamond derivative)
- Verajja Serif (based on Bitstream Vera Serif)
They both have support up to 63/64.
See examples below.

I just noticed the Verajja font, based on BT Vera Sans, also has Alternative Fractions.
The DejaVu Sans fonts included in LibreOffice are also based on Bitstream Vera Sans.
So you may want to try that one if sans serif is best for your application.

http://www.softerviews.org/Fonts.html

-----

Update - adding Verajja (sans) examples (same as LO DejaVu Sans)

Update - adding a working document
OpenType Test - Alternative Fractions.odt
It also shows using a thinspace or hairspace to bring the fraction closer to the big number.

.

more

Thanks for the reply. I am using Libre Office 4.3.7.2 on a Linux Centos 6.9 box. None of the fonts you mention are available on my writer. Also trying to ad the ':frac' after the font name does nothing, it is automatically removed.

( 2018-04-10 00:16:09 +0200 )edit

PT Serif is a free font of the PT font family, just download and install: https://old.paratype.com/public/

( 2018-04-10 13:16:28 +0200 )edit

OpenType support was added in LO 5.2 (I think).
So the old version you are using has no support for OpenType features.

All of the fonts mentioned are included in LO 5.3, and are also freely available on the web for download.

Update to a current version of LO and you will have everything you need.

( 2018-04-10 17:47:32 +0200 )edit

You also may be able to use the "G" fonts. The G stands for Graphite with is an alternative font features system which has been supported in LO/OO much longer than OpenType.
Try this font setting:
Linux Libertine G:frac=1

(On my phone so I cannot test at the moment)

( 2018-04-10 18:43:04 +0200 )edit

OK I now have 5.4 installed and can access those fonts. I am still not happy with the result. I am used to fractions reading as a numerator with a horizontal line below it and the denominator below that. This diagonal divisor bar is new to me and unsightly. Is there no way to get a plain horizontal divisor bar?

( 2018-04-10 22:09:45 +0200 )edit

Yes.
In OpenType those are called Alternative Fractions.
(also called stacked fractions and nut fractions out in the wild)
At my laptop now ... will make some examples and add them to the answer above.

( 2018-04-10 23:14:54 +0200 )edit

Thanks will not get back here until tomorrow afternoon but will look forward to your answer. By the way I installed that LO 5.4 on top of my previous version. Didn't want to uninstall and then not get the new one. Now I have to find a way to get rid of the old one as it stops my writer printing. Any suggestions on Centos 6.9

( 2018-04-11 01:36:19 +0200 )edit

OK. That will give me some more time to organize.

( 2018-04-11 04:04:01 +0200 )edit

Have you tried using a Math formula? You can control precisely the placement of all elements, eventhough it is a bit tedious.

( 2018-04-11 08:33:36 +0200 )edit

OK. Added the Alternative Fractions info to the solution above.
If this helps, please click the up arrow and the checkmark.

( 2018-04-11 23:59:38 +0200 )edit

I am not quite certain what you are trying to do, but I think this may be a possibility. Excuse me if I have misunderstood.

Are you trying to create superscript or subscript fractions? You can do this by defining a Character style and the FONT EFFECT tab allows you specify normal / subscript / superscript. You could define a character style called SUPERSCRIPT, for example.

You can also change the normal font to superscript (CTRL/SHIFT + p) or subscript (CTRL/SHIFT + b). (CTRL/SHIFT +X) resets the line.

Autocorrect also allows you to choose these characters (TOOLS > AUTOCORRECT > AUTOCORRECT OPTIONS) on my system to show the choice. There are also a limited number of fractions available on some fonts. See INSERT > SPECIAL CHARACTER to find them.

more

Hi Peter. I am trying to create labels for mechanical tools. I am aware of the insert special character but that only has quarters etc. I need to write things like 17/64 in a more presentable manner. Which brings me back to where I started. I can create these fractions but cannot align them with the other text. Thus 1 1/8 finishes up with the one and the eighth on apparent different bases according to the line. To do this I am using two different font sizes, which is annoying and slow.

( 2018-04-09 19:01:41 +0200 )edit

I'm not sure but OpenType fonts could be a solution. See here the following link's thread:

( 2018-04-09 19:11:14 +0200 )edit

Using the formula editor

As an alternative, you can use the formula editor (Math component of LO suite) to format your fraction. It does not require OpenType features and works with any font. And, not least, placement of all elements are under your control.

Insert>Object>Formula, then type the required formula, e.g.

"Standard" font size is 12pt, consequently I shrinked the fraction 50% leading to size 6 which is applied to the bracketed block containing the fraction as 7 over 8. Since I found the fraction had not enough weight I added bold which applies to everything at its right.

I used grave accent and tilde spacing elements to experiment with separation between whole part and fraction. You can also use a string of space characters surrounded by quotation marks (a space character is slightly shorter than a tilde space).

Adapt to your case. You can even make it a "template" instead of copy/paste model if you have many labels to create.

EDIT 2018-03-13

Making your custom formula is quite easy. The procedure is described in the Math Guide at end of Chapte 1, Formula library section. Short summary:

<?> " " bold size 21 { <?> over <?> }

2. Return to the Writer document, your formula is displayed with empty square placeholders. Right-click on it and choose Save a copy as from the contectual menu.

3. Navigate to a convenient directory, give it a name and select .odf (LO Math formula) or .mml (MathML) format and Save.

You can now erase the formula or customize it for your needs.

Using this new model is straightforward:

1. Put the cursor where you want to insert another similar formula.
2. Insert>OLE Object (not Formula)
3. In the dialog, check Create from file and click Browse (or similar label -- I'm not presently under the English UI and I translate "logically") to navigate to the directory where you stored your formula, select the formula file and push Open.
4. Push OK, the formula is inserted.
5. Double-click on the formula and use F4 to quickly jump from <?> placeholder to the next one.

You know the rest of the story.

If this answer helped you, please accept it by clicking the check mark ✔ to the left and, karma permitting, upvote it. If this resolves your problem, close the question, that will help other people with the same question.

more

Making this a template sounds to be onb the right lines, however I cannot find any help that shows how to do that without creating a new document. Suggestions please? I have experimented and found to keep the fractions on the same line position as any text I need to include a whole number next to it. If none were present anyway then a dummy number as seen in this example works. size 60 " " bold size 21 { 17 over 64} I still need to figure out how to get this into a template though.

( 2018-04-13 13:17:09 +0200 )edit

Hi LibreTraining I am new here and still finding my way around the site. I have installed that verajja font on my maching but it does not make any difference. I have tried adding the ':afrc' to the end of the font but again it makes no difference. my fractions still look like this 17/64.

more

What version of LibreOffice are you using?
The OpenType features were added in LO v5.3.
In one of your other threads you were going to try LO v5.1 - that will not work.

( 2018-05-15 22:30:57 +0200 )edit

I tried adding 5.4 and installed it but did not get rid of 4.3 first. I now seem to have a mixture of both but which leans toward defaulting to 4.3. I am on Linux centos 6.9. How do I get rid of the older version. Do I have to erase both and then download 5.4 again and if so what happens to my documents etc? When I look at the applications -> office menu I get all the LO apps showing the 5.4 next to them and also the apps without the 5.4. I thought if I selected the 5.4 app I would get that one

( 2018-05-15 23:49:45 +0200 )edit

OK I have removed all of LO and then reinstalled just 5.4. That went well, I then added the Verajja font. If I add the ':afrc' to the end of the font name I still do not get any fractions as I would like them. I am using Verajja Serif 18pt. I even tried creating a style called fractions and set the font there to Verajja Serif:afrc, still with no response. When typing is the fraction supposed to auto adjust or do I have to select it and then do something else?

( 2018-05-16 18:54:03 +0200 )edit

Just saw this - I get no noticed from this thing.

Yes, it should happen automatically as you type.

( 2018-05-25 16:49:03 +0200 )edit

Hi Libre Training Thanks for the reply. I have a screen shot of the results on my machine but cannot see how to put it on here. Please let me know. I have the font installed and added the ':afrc' but nothing happens when i type the numbers which should result in a fraction. Is there another way you can assist with this please? As a matter of interest the usual 1/2, 1/4 do convert to the old type fractions.

( 2018-05-25 20:31:58 +0200 )edit

The common ones like 1/2, 1/3, 1/4, 1/8, 2/3, 3/4, 3/8, etc. are actually replaced by AutoCorrect.
Those can get in the way if you are trying to create OpenType stacked fractions (afrc).
You may want to delete those out of AutoCorrect (or turn off).
Tools > AutoCorrect > AutoCorrect Options

You cannot attach screenshots to comments, but you can to your original Q or A above.
That is once you have enough Karma - you may not.
But you can post a link to an image on Imgur.com or ?

( 2018-05-25 22:04:18 +0200 )edit

Hi Libre Training I have now registered on Imgur and added the screen shot there. https://imgur.com/a/feoVWWm You can see I have the font set correctly and also I have added that afrc to the end of the font. What you see is what happened as I typed it. I also added the about pop up to let you see the version I am running. All help apprectiated

( 2018-05-26 14:36:30 +0200 )edit

I will test that and see if I have any issues.
If it works for me, I will upload a document which I have tested as working properly.
May not be back before Monday (my time US West coast).

( 2018-05-27 00:56:09 +0200 )edit

Tested OK on LO 5.4.6.2.
Attached a working document which I created in LO 5.4.6.2.
See: OpenType Test - Alternative Fractions.odt
At bottom of my answer post.

( 2018-05-27 01:44:02 +0200 )edit