[texhax] Repeating blocks of LaTeX code -- can it be done?
Don Gingrich
gingrich at rmit.edu.au
Thu Jul 10 09:03:37 CEST 2008
What I'm trying to do is simple conceptually, I've got a LaTeX
template for final examinations and I want to put space on the
exam paper for the students to answer. I may not be doing this
the best way presently, and I'm sure I'll hear if there's a better
way to do it. But what I'd also like to do (and I had a look at
_The_LaTeX_Companion_ and didn't find any suggestions) is
to be able to have the code for a vertical space and a horizontal
line and put it in a block with a multiplier to get n lines for some
value of n. Given that TeX and LaTeX behave like a programming
language, I would have thought this was possible.
The relevant lines from the template follow:
\newcommand{\IncludeWritingSpace}{true}
\newcommand{\ansSpace}[1]{\ifthenelse{\equal{\IncludeWritingSpace}{true}} {\\{\bf Write answer here:} #1}{}}
\begin{enumerate}
\item This is an exam question
\answer{ there is a similar block of code to the ansSpace command that allows the answer to be printed
optionally -- for marking guides and for students to review their answers versus the required answers}
% what I would like is to be able to put a multiplier on the combined vspace
% and rule lines to get 2 or more lines for students to write on.
\ansSpace{
\vspace{14pt}\\
\rule[0pt]{14cm}{0.75pt}\\
\vspace{14pt}\\
\rule[0pt]{14cm}{0.75pt}\\
\vspace{14pt}\\
\rule[0pt]{14cm}{0.75pt}\\
\vspace{14pt}\\
\rule[0pt]{14cm}{0.75pt}\\
\vspace{14pt}\\
\rule[0pt]{14cm}{0.75pt}\\
\vspace{14pt}\\
\rule[0pt]{14cm}{0.75pt}\\
}
\item Another question
\end{enumerate}
Thanks,
-Don
--
Don Gingrich
gingrich at rmit.edu.au School of CSIT, RMIT Melbourne, Au
gingrich at acm.org don.gingrich at member.sage-au.org.au
More information about the texhax
mailing list