Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to typeset a formula in LaTeX with a rule name beneath it, such as the following:

Desired output

The code for the rule an automatically-generated mess (not necessarily using maths mode), output from the theorem prover Isabelle/HOL, which I have little control over. My hope was that I could somehow isolate the auto-generated output by using mbox or something similar.

My attempt to generate a macro for generating this output boils down to something like the following once I remove formatting commands:

\newcommand{\myrule}[2]{{
  \begin{minipage}{\textwidth}%
      \mbox{#1} \\
      \mbox{#2}
  \end{minipage}}}

This can then be used as \myrule{\AutoGeneratedOutput}{ParitalPrimeSuc}.

The problem I have is that the vertical space between the two boxes depends on the content of the first box. For example, consider the following example:

\documentclass{article}

\begin{document}

\newcommand{\myrule}[2]{{
    \begin{minipage}{\textwidth}%
        \mbox{#1} \\
        \mbox{#2}
    \end{minipage}}}

\newcommand{\myruleii}[2]{{
    \begin{minipage}{\textwidth}%
        \fbox{#1} \\
        \fbox{#2}
    \end{minipage}\ignorespacesafterend}}

\myrule{\begin{minipage}{1in}line 1\end{minipage}}{last line}

\vspace*{.5in}

\myrule{\begin{minipage}{1in}line 1\\ line 2\end{minipage}}{last line}

\vspace*{.5in}

\myruleii{\begin{minipage}{1in}line 1\end{minipage}}{last line}

\vspace*{.5in}

\myruleii{\begin{minipage}{1in}line 1\\ line 2\end{minipage}}{last line}

\end{document}

The output of this is as follows (images moved to save space):

Actual output

Note that the distance between the bottom of the first mbox and the second mbox (highlighted in blue) differs depending on whether the first parameter has a line-break in it our not.

Interestingly, if I replace the mbox with a fbox, the spacing becomes consistent (highlighted in green). This confuses me somewhat, because an fbox is supposed to be the same as an mbox, other than having a border around it.

Is there a way to get the consistent spacing of fbox without the border? (Or should I be using a completely different mechanism for this?)

share|improve this question

2 Answers 2

\begin{minipage}[b] should help. Then the reference point of the minipage is moved to the bottom element (e.g. line). Then the normal line spacing rules apply, trying \baselineskip for the base lines first.

Otherwise the reference point is vertically in the middle. With several lines the depth of the minipage becomes huge and very likely exceeds \lineskiplimit. Then TeX does not set the space according to \baselineskip. Instead it inserts \lineskip (default: 1pt).

share|improve this answer
    
Thanks for your post. So using \fbox solves my problem simply because the border pushes me over \lineskiplimit? Using \begin{minipage}[b] appears to solve the problem, but after reading up on \lineskiplimit, \baselineskip, \lineskip (which led me to \offinterlineskip), I wonder if adjusting these is a better approach? –  davidg Mar 31 at 5:06
    
@davidg: The distance between the two \fboxes is not larger in your image. The space between the lines is very likely \lineskip = 1pt. The space inside the \fbox does not matter. The dimension of the \fbox is visible by its lines. The spacing inside is controlled by \fboxsep. Therefore \fbox is larger by \fboxsep + \fboxrule in all four directions than a \mbox with the same argument. –  Heiko Oberdiek Mar 31 at 5:16

you could try putting a \strut at the end of the last line in the first box, and another at the beginning of the first line in the second box.

that should enforce the equivalent of a \baselineskip between them.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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