[OS X TeX] Conditional Typesetting Inside Lists
Themis Matsoukas
matsoukas at engr.psu.edu
Tue Feb 26 16:47:19 EST 2008
On Feb 26, 2008, at 10:41 AM, Maurino Bautista wrote:
> I would like to define a variable whose values are either exam or
> key.
> [...]
>
I use the \commentsoff{}, \commentson{} commands that are built-in in
the memoir class (see p. 207 of the memoir manual, meman.pdf). I
believe that these commands are also available through packages, if
you don't want to use memoir. Here is a minimal example. Set the
boolean ShowKey to true or false to show/hide the solution.
Themis
-----
\documentclass[11pt,article]{memoir}
\usepackage{ifthen}
\begin{document}
\newcomment{MyKey}
%-----setup boolean ShowKey----
\newboolean{ShowKey}
\setboolean{ShowKey}{true} %<-- true: shows key; false: hides key
\ifthenelse{\boolean{ShowKey}}
{\commentsoff{MyKey}}
{\commentson{MyKey}}
%----E X A M P L E-----
% problem statement here
\textbf{Problem:} $1+1=?$
% solution here - printed only if ShowKey is true
\begin{MyKey}
\textbf{Solution:} $1+1=2$
\end{MyKey}
\end{document}
More information about the MacOSX-TeX
mailing list