2

I would like to write a list of true-false questions:

  1. Each question should be numbered.
  2. There should be enough underlined space to fill in a single character, i.e. T or F, by hand.
  3. Then the question should follow.

The following MWE shows a list which is very close to what I would like

\documentclass{book}

\usepackage{enumitem}
\newlist{tfl}{enumerate}{1}
\setlist[tfl]{label*={\alph*.\quad\underline{\hspace{0.5cm}}}}

\begin{document}

\section{Exercises}

\begin{enumerate}
\item Mark the following true or false
  \begin{tfl}
  \item Every dog has a tail
  \item Every animal with a tail is a dog
  \item Every dog has four legs
  \item Every animal which barks and is born with four legs is a dog
  \end{tfl}
\item Compute to the last digit the value of $\pi$.
\end{enumerate}

\end{document}

This is how the MWE looks on my screen

My primary concern is to push the entire segment of true-false question to the right.

Specifically, I do not want the column marked by the letters a, b, c, and d, to appear to the left of the column marked by the numbers 1 and 2.

Moreover, I would like to know if there is a cleaner way of setting aside a bit of underlined space, than using \hspace in the definition of \setlist.

However, this last bit is a very secondary concern.


EDIT 1: I am grateful for all the useful information that I have received. I suspect that @Bernard's answer is the one that solves my problem as I am working within the book class. Regretably, my current LaTex installation will not compile it. I am looking into that issue.

However, using suggestions from @Alan Munn and @Skillmun I have constructed another example which might be of use to others. The critical difference between this example and my original MWE is the individual questions span multiple lines. The use of `leftmargin=2cm' or 'leftmargin=*' ensures that these separate lines are nicely aligned.

\documentclass{book}

\usepackage{enumitem}
\newlist{tfl}{enumerate}{1}
\setlist[tfl]{label*=\alph*.\quad\underline{\hspace{0.5cm}},leftmargin=2cm}

    \begin{document}

    \section{Exercises}

    \begin{enumerate}
    \item Mark the following true or false
      \begin{tfl}
      \item Every real number is a floating point number.
      \item Every floating point number is a rational number.
      \item Every real number can be accurately represented by a floating point number.
      \item Every real number in the representable range can be accurately represented by a floating point number.
    \item For every real number $x$ in the representable range, there exists a floating point number $\hat{x}$ such that $\hat{x} = x(1+\delta)$, where $|\delta| \leq u$ and $u$ is the unit round off error.
      \end{tfl}
    \item Compute the IEEE single precision representation of $\pi$.
    \end{enumerate}

    \end{document}

Improved minimal working example

  • Welcome to TeX.se and thanks for posting a minimal example document. The \hspace is a pretty normal way to get the underlined space. See Long underscore in LaTeX for other options. If you add align=left to the list description, does that do what you want? – Alan Munn Aug 17 '17 at 15:06
  • 1
    align=left is an option (like @AlanMunn pointed out), another one could be leftmargin=2cm. – Skillmon Aug 17 '17 at 15:09
  • 1
    @Skillmon Better would be leftmargin=*. – Alan Munn Aug 17 '17 at 15:17
  • @AlanMunn you're right. Didn't consider... – Skillmon Aug 17 '17 at 15:23
  • @AlanMunn: Thank you very much for the pointers. The discussion on the long underscore is very informative. align=left did indeed do what I want for the MWE. When I tested it for my real example, I discovered that my MWE was too minimal! – Carl Christian Aug 18 '17 at 10:23
1

Like this?

\documentclass{book}

\usepackage{enumitem}
\newlist{tfl}{enumerate}{1}
\setlist[tfl]{label*=\alph*.\quad\rule[-0.5ex]{0.5cm}{0.4pt}, wide =0pt, leftmargin=*}

\begin{document}

\section{Exercises}

\begin{enumerate}[wide=0pt, leftmargin=*]
\item Mark the following true or false
  \begin{tfl}
  \item Every dog has a tail
  \item Every animal with a tail is a dog
  \item Every dog has four legs
  \item Every animal which barks and is born with four legs is a dog
  \end{tfl}
\item Compute to the last digit the value of $\pi$.
\end{enumerate}

\end{document}

enter image description here

  • Thank you very much for this answer. It is exactly what I was hoping for. Unfortunately, I get an error message from pdflatex stating that '! Use of \\tfl doesn't match is definition'. There is a few more lines of error messages which I don't know how to parse or reproduce here, but it is the first \item in the true-false list which triggers it. I have pdfTeX, Version 3.14159265-2.6-1.40.15. – Carl Christian Aug 18 '17 at 10:42
  • Do you have the error message with this very code? – Bernard Aug 18 '17 at 10:54
  • Yes. Give me a moment and I will post a link to it. – Carl Christian Aug 18 '17 at 11:19
  • Here is a link to a .txt file with the output form pdflatex. www8.cs.umu.se/~spock/bernard-error.txt It continues indefintely, so I had to cut it short. It seems to cycle through the same few statements. The link has a complete cycle. – Carl Christian Aug 18 '17 at 11:27
  • I can't say much as I don't have the real code you compiled. The definition of the tfl environment is just yours, so if you compiled exactly the above code, you should obtain a normal compilation. I don't think that compiling with TeX Live 2015 matters here (albait you should update anyway). – Bernard Aug 18 '17 at 11:40
1

You need to use the exam class in order to achieve what you are looking for (plus a lot more).


Here is the code:

\documentclass{exam}

% \printanswers

\newcommand{\tfq}[1][{}]{%
  \fillin[#1][10.0mm]}

\begin{document}

\section{Exercises}

\begin{questions}
\question [4] Mark the following true or false
  \begin{parts}
    \part \tfq[T] Every dog has a tail.
    \part \tfq[F] Every animal with a tail is a dog.
    \part \tfq[T] Every dog has four legs.
    \part \tfq[F] Every animal which barks and is born with four legs
    is a dog.
  \end{parts}

  \question [6] Compute to the last digit the value of $\pi$.
\end{questions}

\end{document}

The output:

enter image description here


To print the answers, simply uncomment the % \printanswers line.

To start other customization, e.g. point position, appearance etc. see the exam documentation.


Tips

To place points in the right hand margin, I find the following very convenient:

\usepackage[dvips,pdftex,legalpaper,top=10.0mm,bottom=15.0mm,includeheadfoot,left=20.0mm,right=25.0mm]{geometry}

\pointsinrightmargin
\setlength{\rightpointsmargin}{10.0mm}
  • Thank you very much for all this useful information! I l learn more about the exam class for future use. Right now, I really am bound by the book class. – Carl Christian Aug 18 '17 at 10:33
  • @CarlChristian You are most welcome. Once you start using the exam class, you will find that this is the tool you want to use for all your examinations. – Masroor Aug 18 '17 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.