how to format fractions with a horizontal bar

How do I write a fraction with a horizontal division bar?

Out of curiosity: For what purpose do you want this?

I really would want to know.
If it’s nothing concerning calculations, why is it tagged calc? Fractions - or any mathematical stuff needing to be shaped in a specific way (for a printout or a presentation e.g) should be created/edited with a formula editor. That’s for what LibreOffice has the Math component. The objects are inserted into whatever kind of document by OLE then. To type %pi approx 355 over 113, to select this, copy or cut it .and finally paste it into a Math panel is simple if compared with thinkable workarounds.
In Writer it’s sufficient to call Insert Formula after the selection. The result is easily moved to a Calc document or elsewhere then.
Even to create a “scratch” document in Writer for as long as needed to ease the process is fast…

You can’t (unless you insert a Math formula object with which you can’t calculate).

Unless you use the iMath extension in Writer

This might not be a method for sharing documents as it uses font features that might not be available with a substitute font. It works only for simple fractions.

Format your cell with a suitable font with the needed attributes, e.g. Linux Libertine Display G.

Enter your fraction, say 2/5, select the characters and right click. From the context menu select Character. In the dialog that opens select the Font tab, at the bottom right there is a button Features, click on it.

In the new dialog there a font characteristics that you can select. You want nut fractions so select that and OK out.

You could also just select your fraction characters, then paste in the Font Name box Linux Libertine Display G:frac=2. Cheers, Al