5

I would like to define a command that takes three arguments; a question number, the question text from the problem, and finally my answer. Though there are a lot of different solutions out there I am sure but I do not know what is the right answer. One of the complications is that I would like all of the questions and answers (not the question number) left aligned with each other regardless of the width of the question number (1.1 vs 1.10). I have produced something to begin but I am getting a strange error that I simply do not follow. Here is the code:

\documentclass[letterpaper,10pt]{article}

\newcommand{\question}[3]{
\begin{itemize}
\item[\makebox[1cm][l]{#1}] #2

\vspace{.2in}

#3

\end{itemize}
}

\begin{document}

\question{a}{b}{c}

\end{document}

When I execute this, the result is the following:

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/MacPorts 2013_6)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 43 languages loaded.
(/opt/local/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/opt/local/share/texmf-texlive/tex/latex/base/size10.clo)) (./test.aux)
! Argument of \@makebox has an extra }.
<inserted text> 
                \par 
l.18 \question{a}{b}{c}

? ^D
! Emergency stop.
<inserted text> 
                \par 
l.18 \question{a}{b}{c}

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on test.log.

Any suggestions on what I am doing wrong? Thanks for any help.

0

1 Answer 1

7

Your problem is similar in nature to Right square bracket at the end of an item label adds space before it - different cause; same result/solution. In your definition of \question you should use

\newcommand{\question}[3]{%
  \begin{itemize}
    \item[{\makebox[1cm][l]{#1}}] #2

      \vspace{.2in}

      #3

  \end{itemize}
}

Note how the argument supplied to the optional \item argument is wrapped in braces to avoid confusion as to where arguments end.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .