22

I want to write as a math fraction 1/4 " ( a quarter of inch). I want to write this fraction out of an equation because is a characteristic of an element.

migrated from stackoverflow.com Dec 30 '11 at 20:21

This question came from our site for professional and enthusiast programmers.

  • 2
    @lostinplace I don't think this is a Mathematics question – user1016253 Dec 30 '11 at 16:37
35

Without hassle, use 1/4 as-is, or $\frac{1}{4}$ (similar to amsmath's \tfrac{1}{4}) will typeset one quarter. If you want to add " in order to represent "inches", you could use $\frac{1}{4}''$, which is equivalent to $\frac{1}{4}^{\prime\prime}$. xfrac also produce so-called "vulgar fractions" via \sfrac{<num>}{<denom>}. Here are some examples:

enter image description here

\documentclass{article}
\usepackage{xfrac}% http://ctan.org/pkg/xfrac
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum eu $1/4^{\prime\prime}$ massa lectus. 
Phasellus eget $\frac{1}{4}^{\prime\prime}$ tortor mi, porttitor aliquam lacus. Donec rutrum, purus eu luctus rhoncus, 
nunc enim $\sfrac{1}{4}''$ viverra metus, et iaculis urna enim ut sapien. Aenean malesuada, orci eget 
facilisis pretium, metus dolor dapibus justo, eget laoreet $\frac{1}{4}^{\prime\prime}$ leo eros sit amet massa. 
Duis viverra eleifend elementum. Proin volutpat tristique luctus. In non erat quam. 
Ut porta hendrerit $\sfrac{1}{8}''$ sapien sit amet molestie. Aliquam erat volutpat.
\end{document}

Note that there might be some spacing issues if you use two "text fractions" in successive lines, since the ascenders and descenders of the respective lines push them further apart (lines 1-3 exhibit this stretched look). As such, the "vulgar fractions" are sometimes preferred, since they take up less vertical real estate.

  • Isn't it different text fonts when using the $-environment? Can you get \frac-like fractions but with the text font? – Lars Abrahamsson Oct 14 '18 at 9:39
  • @LarsAbrahamsson: Sure, try with \frac{\text{<num>}}{\text{<denom>}} if you're loading amsmath. – Werner Oct 14 '18 at 16:08
4

You can create nice split level fractions with the nicefrac package, or, if you have reasonably recent TeX distribution, with the xfrac package.

\documentclass{article}
\usepackage{nicefrac}

\begin{document}
Blah blah blah \nicefrac{1}{4} blah blah blah.
\end{document}

or

\documentclass{article}
\usepackage{xfrac}

\begin{document}
Blah blah blah \sfrac{1}{4} blah blah blah.
\end{document}

The xfrac package is more flexible, and will work better with much larger variety of fonts.

  • 2
    adding images of what they look like would be nice... – John D Jun 22 '18 at 23:33
  • \sfrac is not split-level as far as I know? – Lars Abrahamsson Oct 14 '18 at 9:36
3
\begin{equation}
\frac{1}{4}
\end{equation}

EDIT:

or

\begin{eqnarray}
\frac{1}{4}
\end{eqnarray}

or

$ \frac{1}{4} $
  • out of equation. I put this fraction in a cell of a table. – Jorge Vega Sánchez Dec 30 '11 at 16:56
  • @JorgeVegaSánchez Forgive me I misread, see the edit – user1016253 Dec 30 '11 at 17:12
  • 6
    Please see \eqnarray vs \align on why to avoid using eqnarray. – Werner Dec 30 '11 at 20:26
1

I don't understand the context of your question. LaTeX provides the much overused $\frac{1}{4}$ but this has several disadvantages, especially if it's used in ordinary math mode (as part of the running text). First, it changes the size of the figures in the numerators and denominators, and second it may screw up the interline spacing. If you just want to write something simple stating that y is a quarter of x then I suggest you write $y=x/4$. Writing this is easier on the eye than $y=\frac{1}{4} x$. For more complex statements, writing $4 y = x$ or (better?) $x = 4 y$ may look better than $y=\frac{1}{4} x$.

In displayed math, similar comments may apply.

  • 1
    Don't forget, you can further condense \frac{1}{4} as \frac14, with an identically good/bad result. ;) – qubyte Dec 31 '11 at 11:58
  • Damn, missed that opportunity! – qubyte Dec 31 '11 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.