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.

While creating a quiz, I needed to format logical arguments, which our textbook presents as a list of premises, one per line, then a horizontal rule as wide as the widest premise, and the conclusion underneath. There should not be too much space around the rule (it does not take up a line of its own.)

I dealt with this by using the pbox package (I have version 1.2.) I put the premises and conclusion in a pbox, with an \hrule before the conclusion. Since the \pbox was the width of the widest line, the \hrule was also the right width. Here is a minimal example.

\documentclass{minimal}
\usepackage{pbox}
\begin{document}
\pbox{8cm}{
Either you love logic or you hate it. \\
You don't hate logic.
\smallskip\hrule\smallskip
You love logic.}
\end{document}

This works fine, actually, except that it produces an error: You can't use `\hrule' here except with leaders. After pressing enter to ignore the error, it is output exactly as I would hope, except that having to press enter 9 times each time I compile my document is not very nice. The quiz looks like this:

Logical Arguments

This raises a 4-fold question:

  1. What is the reason for the error, which only seems to arise in a \pbox? I would love an explanation of the TeXnical underpinnings.
  2. How should one draw a horizontal line across a \pbox without error? I found that \hrulefill works, but needs its own line. Is there a more elegant way than \\[-.7em] \null\hrulefill\\[-.2em], which has the disadvantage of fiddly spacing (liable to break down, and only approximating the spacing of \smallskip\hrule\smallskip, which I liked)?
  3. Is there a way to use \leaders, as suggested by the error, to maintain the same output produced by \hrule but without the error?
  4. What's the proper way to achieve my desired result? I suppose the obvious method is with a tabular environment, but this does not seem semantically correct to me. A succession of statements, with a line underneath, is not a table! Also, the line does not fit the width quite as nicely as it does in a \pbox, though I'm sure that can be fixed with fiddling.
share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Addressing only item 4, hiding the tabular inside a macro \logicarg{<premise>}{<conclusion>} might be more appealing:

enter image description here

\documentclass{article}
\newcommand{\logicarg}[2]{% \logicarg{<premise>}{<conclusion>}
  \begin{tabular}[t]{@{}l@{}}
    #1 \\ \hline #2
  \end{tabular}%
}
\begin{document}
\begin{enumerate}
  \item \logicarg
    {If you are eating soup then I am happy. \\ You are eating soup}
    {I am happy}
  \item \logicarg
    {If it is Wednesday then you aren't taking a quiz. \\ It is not Wednesday.}
    {You are taking a quiz.}
  \item \logicarg
    {Either you love logic or you hate it. \\ You don't hate logic.}
    {You love logic.}
\end{enumerate}
\end{document}
share|improve this answer
    
I've accepted this answer, since it's the method I'll actually use, but David's answer addresses parts 1, 2, and 3. Thank you both. –  Kundor Feb 3 '13 at 23:31
add comment
\documentclass{minimal}
\usepackage{pbox}
\begin{document}
\pbox{8cm}{
Either you love logic or you hate it. \\
You don't hate logic.
\smallskip
\endgraf
\ifvmode\nointerlineskip\fi
\leavevmode\leaders\hrule height 1pt \hfill\mbox{}\endgraf
\smallskip
You love logic.}



\end{document}

You can't use \vrule in vertical mode and you can't use \hrule in horizontal mode but it's a bit delicate on pbox as it measures things in hmode first and then sets a paragraph. \pbox is mostly a tabular environment it would be simpler to use one directly for this usage probably.

share|improve this answer
    
your syntax in the last sentence is rather tortured. i'd edit it, but i'm not entirely sure how to keep your meaning. –  barbara beeton Feb 2 '13 at 18:35
    
@barbarabeeton yes it was 3 in the morning:-) –  David Carlisle Feb 2 '13 at 19:00
    
Wow—I guess that answers #3, and it's ugly enough to make using tabular more palatable! ;-) Although, it doesn't quite reproduce the behavior of the error-producing \smallskip\hrule\smallskip—there's more space left afterwards, even if I remove the second \smallskip in your code. I didn't realize that \pbox is built with tabular; knowing that makes Werner's solution all the better. –  Kundor Feb 2 '13 at 21:52
add comment

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.