7

I'd like to create a document containing "fractions" with three or more stories instead of just two, separated by fraction bars of equal length. (These aren't real fractions, but I want to use fraction bars for the notation.)

Two things I've tried are the matrix environment with \hlines, and simply nesting \fracs. Neither one produces a satisfactory result:

Two three-story fraction workarounds

The matrix option, on the left, looks pretty decent, but the \hlines are far too wide; they should be barely wider than each story of the fraction. With the nested \frac option, however, the two bars are of slightly different widths, the entire fraction has incorrect vertical positioning (it's centered on the lower bar, instead of the center story), and the vertical spacing is dubious.

\begin{matrix}
N I \\ \hline
I N \\ \hline
a I
\end{matrix}
= \frac{\dfrac{I a}{\N I}}{I N}

Is there a nice way to get multi-story fractions?

2
  • 2
    Welcome to TeX.SX! If these are really fractions this is not a good idea, the notation becomes ambiguous. Commented Sep 19, 2014 at 13:35
  • Thanks. Indeed, these aren't real fractions; they're something else that I want to use the same notation for. Commented Sep 20, 2014 at 20:31

1 Answer 1

12

Environment array can be used:

\documentclass{article}

\newcommand*{\threefrac}[3]{%
  \begin{array}{@{\,}c@{\,}}%
    #1\\
    \hline
    #2\\
    \hline
    #3%
  \end{array}%
}

\begin{document}
\[
  \threefrac{NI}{IN}{aI} = \threefrac{Ia}{NI}{IN}
\]
\end{document}

Result

The lines are longer on each sides by a thin space (\,). This can be changed, if the lines should be smaller or larger.

Uniform spacing around the lines

Here a variant with uniform line spacing using \halign. The vertical space can be configured by redefining \threefracLineSep.

\documentclass{article}

\newcommand*{\threefrac}[3]{%
  \ensuremath{%
    \vcenter{%
      \halign{\hfil$\,##\,$\hfil\cr
        #1\cr
        \noalign{\kern\threefracLineSep}%
        \hline
        \noalign{\kern\threefracLineSep}%
        #2\cr
        \noalign{\kern\threefracLineSep}%
        \hline
        \noalign{\kern\threefracLineSep}%
        #3\cr
      }%
    }%  
  }%
}
\newcommand*{\threefracLineSep}{.4ex}

\begin{document}
\[
  \threefrac{NI}{IN}{aI} = \threefrac{Ia}{NI}{IN}
  \neq \threefrac{\sum\limits_{n=1}^\infty NI^n}{\dots}{n}
\]
\end{document}

Result

3
  • i think these would look nicer with uniform vertical spacing around the rules. (i still wouldn't have any idea what is meant.) a zero-width vertical element could be defined to add a bit more height on the two bottom rows, the amount of height requiring experimentation. this wouldn't interact with superscripts if they occur, unlike an added skip with \\[...]. subscripts are probably already accommodated by the implicit descenders. Commented Sep 19, 2014 at 15:07
  • @barbarabeeton I have added a variant with uniform spacing around the rules. Commented Sep 19, 2014 at 15:20
  • nice! (i hadn't thought of the "degenerate" case you show on the right.) even though you'll probably get grumbles about "descending" into non-latex code. Commented Sep 19, 2014 at 15:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .