13

I'm trying to display some axioms and operational rules with LaTeX.

Those are basically . They work quite well when used with frac, but it's not really nice, I'd like the fraction line to be a bit longer.

I know that sounds a bit vague, so here is a picture of what I am trying to achieve. I'm pretty sure that document has been typeset in LaTeX, so it should be doable. Photo of what I am trying to achieve

5
\newcommand\bigfrac[2]{%
  \begin{array}{c}
    #1 \\
    \hline
    #2
  \end{array}}
2
  • Thanks. I wanted to give it a little more space under the line (the letters over the arrows now almost touch it) so I tried: \newcommand\bigfrac[2]{\begin{array}{c}#1\\\hline\vspace{1pt}#2\end{array}} but that just increased the space between the two lines in the picture. Jun 25 '11 at 12:55
  • 2
    Add \begingroup\setlength\extrarowheight{1pt} before \begin{array} and \endgroup after \end{array}. Load the array package.
    – egreg
    Jun 25 '11 at 12:59
22

Here's an extended version of \frac, supporting an optional argument for a wider line:

\documentclass{article}
\DeclareRobustCommand{\frac}[3][0pt]{%
  {\begingroup\hspace{#1}#2\hspace{#1}\endgroup\over\hspace{#1}#3\hspace{#1}}}
\begin{document}
\[
  \frac{x}{y} \quad \frac[5pt]{x}{y}
\]
\end{document}

enter image description here

Of course you can define your own frac command similar instead of redefining the existing \frac, also with a default value bigger than 0pt.

The definition is similar to the definition in amsmath.sty, except that file is using \@@over.

Or, you could define your own macro using the original \frac:

\DeclareRobustCommand{\widefrac}[3][5pt]{%
  \frac{\hspace{#1}#2\hspace{#1}}{\hspace{#1}#3\hspace{#1}}}
...
\widefrac{x}{y} ... \widefrac[8pt]{x+y}{y}
4
  • 3
    Note that the use of \over together with amsmath will lead to Package amsmath Warning: Foreign command \over. Jun 25 '11 at 13:23
  • 2
    With amsmath the command \@@over can be used instead, exactly in the same way plus \makeatletter and \makeatother. amsmathdefines: \@saveprimitive\over\@@over.
    – Stefan Kottwitz
    Jun 25 '11 at 13:26
  • Why not restore the old \frac and use it here? Or use \genfrac provided by amsmath.
    – Leo Liu
    Jun 25 '11 at 17:25
  • 1
    @Leo: added an example re-using \frac. Of course it could be done similar with \genfrac.
    – Stefan Kottwitz
    Jun 25 '11 at 17:51
13

In case you really want fractions with a longer line, you can just pad both numerator and denominator with spaces. (Padding the longer of the two would acually suffice.) \frac{\ a\ }{\ b\ } gives

For a longer line use, e.g., \quad instead of \ .

2
  • OK, Stefan just posted a better version of this. Jun 25 '11 at 13:21
  • Stefan's solution is better, but your solution is simpler.
    – vesszabo
    Dec 27 '19 at 17:30
3

You should consider to use a dedicated package to write your axioms; the bussproofs package could be an option:

\documentclass{article}
\usepackage{bussproofs}
\usepackage{amsmath}

\newcommand*\LArrow[1][a]{\xrightarrow{\phantom{a}#1\phantom{a}}}

\begin{document}

\begin{prooftree}
  \AxiomC{$x\LArrow x^\prime$}
  \UnaryInfC{$x+y\LArrow x^\prime$}
\end{prooftree}

\end{document}

enter image description here

To work with displayed math environments, a better option would be to use the proof package. A little example:

\documentclass{article}
\usepackage{proof}
\usepackage{amsmath}

\newcommand*\PA{\phantom{a}}
\newcommand*\LArrow[1][a]{\xrightarrow{\PA#1\PA}}

\begin{document}

\begin{equation}
  \infer{\PA x+y\LArrow x^\prime\PA}{x\LArrow x^\prime}
  \qquad
  \infer{\PA x+y\LArrow y^\prime\PA}{y\LArrow y^\prime}
  \qquad
  \infer{\PA x+y\, \downarrow\PA}{x\,\downarrow}
  \qquad
  \infer{\PA x+y\, \downarrow\PA}{y\,\downarrow}
\end{equation}

\end{document}

enter image description here

3
  • Looks better, but I don't need more functionality than the answer above provided. Plus, I can't get it to work in a displaymath environment. Jun 25 '11 at 13:04
  • Interesting ! a discover for me Jun 25 '11 at 13:06
  • @Tim van Dalen: see my updated answer. Jun 25 '11 at 13:51
0

Another solution is to use the \phantom{} command, which renders the exact whitespace the exact same size as its argument.

For example,

\documentclass{article}
\usepackage{proof}
\usepackage{amsmath}

\begin{align*}
\varphi &= 1+ \frac{1}{1 + \cfrac{1}{\varphi}}\\[.5cm]
%
%
\varphi &= 1+ \frac{ \phantom{\longrightarrow} 1 \phantom{\longrightarrow} }{1 
+ \cfrac{1}{\varphi}}
\end{align*}

\end{document}

which returns

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.