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?

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.

You can download these font files and specimen sheets here:
http://www.softerviews.org/Fonts.html

If this solves your issue please check the checkmark at left.


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.

OpenType Test - Alternative Fractions.odt


If this solves your issue, please check the checkbox at left.

.

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.

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

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.

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)

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?

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.

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

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

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

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

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?

If I add the ‘:afrc’

You should try :frac. If none of the options work, the font don’t support it.

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.

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.

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

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.

image description

(made with Liberation Serif)

“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:

  1. Create your formula in your current document as:

    <?> " " 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 :heavy_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.

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.

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.