4

I am trying to align several proofs produced with the infer command from the proof package.

I want to be able to produce the following: enter image description here

But I cannot align is this way. Here is a minimal example:

\documentclass{article}
\usepackage{proof}
\begin{document}
\[
  \begin{array}{cc}
    \vcenter{\infer[rule~name]{equation}{equation}}
    &
    conditions\ \vcenter{\infer[rule~name]{equation}{equation}}
    \\[1.5em]
    conditions\ \vcenter{\infer[rule~name]{equation}{equation}}
    &
    \vcenter{\infer[rule~name]{equation~maybe~longer}{equation}}
  \end{array}
\]
\end{document}

which produces the following: enter image description here

  • 1
    So you want centering with respect to the inference lines? – egreg Jun 13 '14 at 15:16
  • Yes, exactly that. – Alejandro DC Jun 13 '14 at 15:18
  • You can do this without the \infer command... – Werner Jun 13 '14 at 16:23
  • Do you have several of these bizarre alignments or it's just a few shots? – egreg Jun 13 '14 at 17:30
  • This time, there are many more, not only four. – Alejandro DC Jun 13 '14 at 23:33
3

You can measure the items and then set the condition and rule name parts pretending they have no width:

\documentclass{article}
\usepackage{proof,environ,array}

\newcommand\centerinfer[4]{%
 % #1=condition, #2=rule name, #3=lower, #4=upper
 \ifcenterinfermeasure
   $#1\ \vcenter{\infer{#3}{#4}}\ #2$%
 \else
   \llap{$#1$\ }\vcenter{\infer{#3}{#4}}\rlap{\ $#2$}%
 \fi
}
\newif\ifcenterinfermeasure
\NewEnviron{infertable}
 {\centerinfermeasuretrue
  \setbox0=\vbox{tabskip=0pt
    \renewcommand\\[1][]{\cr}%
    \halign{##&##\cr
    \BODY\crcr}
    \setbox0=\lastbox
    \setbox0=\hbox{\unhbox0 \unskip\setbox2=\lastbox\unskip\setbox4=\lastbox
      \global\dimen1=\wd4 \global\dimen3=\wd2 }
  }%
  \centerinfermeasurefalse
  \begin{tabular}{%
    @{}
    >{\centering$\displaystyle}p{\dimen1}<{$}
    >{\centering\arraybackslash$\displaystyle}p{\dimen3}<{$}
    @{}
  }
  \BODY
  \end{tabular}
}

\begin{document}
\[
\begin{infertable}
\centerinfer{}{rule~name}{equation}{equation} &
  \centerinfer{conditions}{rule~name}{equation}{equation}
\\[1.5em]
\centerinfer{conditions}{rule~name}{equation}{equation} &
  \centerinfer{}{rule~name}{equation~maybe~longer}{equation}
\end{infertable}
\]
\end{document}

enter image description here

  • Amazing! This is exactly what I was looking for. Thank you very much. – Alejandro DC Jun 14 '14 at 21:25
1

Alignment without the proof package is possible with some "box manipulation" (phantoms and overlapping):

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
  \begin{array}{c}
    \phantom{\text{conditions}}\ \dfrac{\text{topA}}{\text{bottomA}}\ \rlap{\text{rule nameA}}\phantom{\text{rule name rule B}} \\ \\
    \text{conditions}\ \dfrac{\text{topBtopB}}{\text{bottomB}}\ \text{rule name rule B}
  \end{array}
\]
\end{document}

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.