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.

I wonder if there is already a package that makes me create a spot the error kind of test like the one below:

enter image description here

This must preferably be in an enumerate environment.

I tried a tikz approach but I could not make it work out.

\documentclass[10pt]{article}

\usepackage{tkz-base}
\usetkzobj{all}


\begin{document}

\begin{enumerate}
\item The principal \tikz [remember picture] \node (said) {}; that \tikz [remember picture] \node (weather) {}; the government \tikz [remember picture] \node (announces) {}; a holiday or not, his school \tikz [remember picture] \node (hold) {}; classes. \tikz [remember picture] \node (error) {};
\end{enumerate}


\begin{tikzpicture}[remember picture]
\def\abovebelow#1#2#3{
\node at (#1) {\underline{#2}};
\node [below=1pt of #1] {#3};
}

\abovebelow{said}{said}{A}
\abovebelow{weather}{weather}{B}
\abovebelow{announces}{announces}{C}
\abovebelow{hold}{will still hold}{D}
\abovebelow{error}{NO ERRROR}{E}
\end{tikzpicture}

\end{document}

Below is the output.

enter image description here

I am looking for a general solution, something that can be used in list environments.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

enter image description here

I don't think you need a drawing package here, I just used tabular:

\documentclass[10pt]{article}

\newcounter{qn}
\renewcommand\theqn{\Alph{qn}}
\newcommand\qn[1]{%
{\refstepcounter{qn}\begin{tabular}[t]{@{}l@{}}#1\\
\noalign{\vskip-.2ex}\hline\noalign{\vskip.2ex}\multicolumn{1}{c}{\theqn}\end{tabular}}}

\newcommand\qnx{{%
\par\qn{NO ERROR}\setcounter{qn}{0}}}

\begin{document}

\begin{enumerate}
\item The principal \qn{said} that \qn{weather} the government \qn{announces} a holiday or not, his school \qn{will still hold} classes. \qnx
\end{enumerate}


\end{document}
share|improve this answer
    
Thanks for the speedy reply. What does \restepcounter do? I think it is more beautiful to change from left alignment to centered. The pictures I posted might suggest that the no error choice is on separate paragraph but that's easily settled by removing \par in the definition. –  hpesoj626 Sep 25 '12 at 11:55
1  
\refstepcounter is just "counter=counter+1", with some additional stuff that makes it work correctly in sectioning counters (i.e. to make "subsection=0" whenever "section=section+1"). Here, \stepcounter could be used to, which does not do this additional stuff. –  tohecz Sep 25 '12 at 11:58
1  
you could use \stepcounter but if you use \refstepcounter you can go \qn{\label{zzz}weather} ... you might want to look closely at \ref{zzz} Basically whenever you auto-number something it's a good idea to use refstepcounter as you always wish later you could refer to it That's why I used refstepcounter before the table in its own group rather thanjust before the counter is printed so it is in scope for a \label in the argument –  David Carlisle Sep 25 '12 at 12:03
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.