Why do i have error by removing this >{\stepcounter{tfno}\thetfno.}

i followed the instructions by this link: Remove the automatic generation of number? and happily satisfied when it really prevented the automatic numbering of the text. But why is when i changed the document class to \documentclass{exam} it suddenly provides me eror. i have this code here:

\documentclass{exam}
\usepackage{amssymb,graphicx}
\usepackage{array}
\usepackage{longtable}
\newcounter{tfno}
\renewcommand\arraystretch{2}
\newcommand{\mybox}{\resizebox{.5cm}{!}{\raisebox{-.5ex}{$\Box$}}}

\newenvironment{truefalse}{%
\setcounter{tfno}{0}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{cp{.5\textwidth}@{\extracolsep{\fill}}cc}
\multicolumn{1}{r}{}&  & \fbox{\parbox{.75cm}{True}} & \fbox{\parbox{.75cm}
{False}}  \\
}{%
\end{longtable}
}
\newcommand\tfquestion[1]{ & #1 & \mybox  & \mybox  \\}
\begin{document}
\begin{questions}
\begin{truefalse}
\question\tfquestion{This is a sample text.}
\question\tfquestion{This is another sample short text.}
\question\tfquestion{This is a long line containing text and wrapping into
second line without hitting the boxes}
\end{truefalse}
\end{questions}
\end{document}


How can I fix the error?

-

The questions environment of the exam class is a list environment, and you try to put a longtable within it, no wonder you bump into problems.

I followed the links to your two other questions, and you should have from the start mentioned that your intent was to use the exam class. This would have avoided to people to spend time on providing solutions which end up being incompatible with this requirement.

I recommend you read the manual of the exam class, as it provides some possibilities for customize the format of question (I am not familiar with it but I saw there is macro called \qformat). In the meantime the following provides something like what you seem to be trying to achieve:

\documentclass{exam}
\usepackage{amssymb,graphicx}

\newcommand{\mybox}{\resizebox{.5cm}{!}{\raisebox{-.5ex}{$\Box$}}}
\newcommand\tfquestion[1]{%

\begin{document}

\begin{questions}
\question\tfquestion{This is a sample text.}
\question\tfquestion{This is another sample short text.}
\question\tfquestion{This is a long line containing text and wrapping into
second line without hitting the boxes}
\end{questions}

\end{document}


As per OP's request, I can propose the following. This is a bit complicated because I wanted to make absolutely sure that no page break would ever happen after the True-False boxes and before the actual questions.

But: I am not even sure the questions environment of the exam class is supposed to be used many times; indeed doing that generates multiply-defined labels errors, and I tried it in a vanilla example just using the exam class and nothing from the code here, just repeated questions environments. The work put into making the page-breaks impossible at the wrong places may just have been a bit in waste if one is supposed to use only once this environment (the manual is long and I did not have time to read it).

The environment is called truefalsequestions and each item is to be input as \tfquestion{the text of the question within braces like this}. There is an optional parameter which defaults to .9 and says how much of the available space is to be used as width of the multi-lines questions.

\documentclass{exam}
\usepackage{amssymb,graphicx}

% \newcommand\tfquestion[1]{%

\newsavebox{\TrueBox}
\sbox{\TrueBox}{\fboxrule1pt\fbox{True}}

\newsavebox{\FalseBox}
\sbox{\FalseBox}{\fboxrule1pt\fbox{False}}

\newcommand{\mybox}{\resizebox{.5cm}{!}{\raisebox{-.5ex}{$\Box$}}}

\newsavebox{\TwoBoxes}
\makebox[\wd\FalseBox]{\mybox}}

\newcommand\tfquestion[1]{} % will be overwritten

\makeatletter
\newenvironment{truefalsequestions}[1][.9] % defaults to 90% of available space
{\renewcommand\tfquestion[1]{%
\question
\parbox[t]{#1\dimexpr\textwidth-\leftmargin-\wd\TwoBoxes\relax}{##1}%
\hfill\usebox{\TwoBoxes}}%
\par\bigskip
\nointerlineskip
\kern\medskipamount\nopagebreak
\@nobreaktrue
\begin{questions}}
{\end{questions}}
\makeatother

\begin{document}

\begin{truefalsequestions}
\tfquestion{This is a sample text.}

\tfquestion{This is another sample short text.}

\tfquestion{This is a long line containing text and wrapping into
second line without hitting the boxes. This is a long line containing text and
wrapping into second line without hitting the boxes.}

\tfquestion{This is a sample text.}
\end{truefalsequestions}

\begin{truefalsequestions}[.6]
\tfquestion{This is a sample text.}

\tfquestion{This is another sample short text.}

\tfquestion{This is a long line containing text and wrapping into
second line without hitting the boxes. This is a long line containing text and
wrapping into second line without hitting the boxes.}

\tfquestion{This is a sample text.}
\end{truefalsequestions}

\end{document}


-
How will i include the "TRUE" "FALSE" as column labels found in this link tex.stackexchange.com/questions/84646/…?? –  Kayla Feb 27 '13 at 14:16