2

I have this idea to create a piece of code that would allow me for a handy introduction of arguments in my notes for students, by which I mean this kind of fractional notation:

enter image description here

I need a command that would adjust the horizontal line by measuring premises and conclusion, and would add 0.5em (or whatever) on each side beyond the sentences. Using ifthen package I came up with this very imperfect (to put it mildly) three-argument \inference command:

\newlength{\premiseone}
\newlength{\premisetwo}
\newlength{\conclusion}
\newcommand{\argument}[3]{%
\settowidth{\premiseone}{#1}
\settowidth{\premisetwo}{#2}
\settowidth{\conclusion}{#3}
\addtolength{\premiseone}{1em}
\addtolength{\premisetwo}{1em}
\addtolength{\conclusion}{1em}
\ifthenelse{\lengthtest{\premiseone > \premisetwo}}%
{\ifthenelse{\lengthtest{\premiseone > \conclusion}}%
{\dfrac{\parbox{\premiseone}{\center #1\\#2}}{\mbox{#3}}}%
{\dfrac{\parbox{\conclusion}{\center #1\\#2}}{\mbox{#3}}}%
}

It is specifically designed for arguments with exactly two premises and has rather unwelcome features because of it. For example, if I write, e.g., \argument{the only premise}{}{the consequence}, LaTeX complains that there is no line to end, and If I add some empty box I have this unwanted additional space, either above the argument or inside it:

![enter image description here

Here are my questions to you:

  1. How could I get round the problem of additional spaces? That is, how could I skip some arguments by writing \argument{the only premise}{}{the consequence} without obtaining this additional vertical space (either above or inside)?
  2. Is there any relatively easy way to build a command which would not be designed for a specific number of premises, but would work in a similar way as mine yet for any finite number of premises? Of course, I could always build \argumentone, \arguemtttwo, \argumentthree, but this is going round the houses.
  • What is wrong with a simple tabular? – campa May 14 at 17:45
  • Well, nothing I suppose :) This is mainly curiosity driven question, I am courious how this could be written in LaTeX. – Mad Hatter May 14 at 17:53
2

I would go with a simple tabular:

\documentclass{article}

\newcommand*{\inference}[3][t]{%
   \begingroup
   \def\and{\\}%
   \begin{tabular}[#1]{@{\enspace}c@{\enspace}}
   #2 \\
   \hline
   #3
   \end{tabular}%
   \endgroup
}

\begin{document}

First example:
\inference{John is taller than Jane}{John is taller than Judy}

\bigskip

Second example:
\inference{John is taller than Jane \and Jane is taller than Judy}{John is taller than Judy}

\bigskip

Third example (vertically centred):
\inference[c]{John is taller than Jane \and Jane is taller than Judy \and Whatever else}{John is taller than Judy}

\end{document}

enter image description here

I added an optional argument for vertical placing. Of course, further additional space above/below the tabular can be added (that will depend on how this thing is used in a real document).

| improve this answer | |
  • Much simpler than my original idea, and does exactly what I need. Thanks a lot! – Mad Hatter May 14 at 18:07

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.