## LaTeX forum ⇒ Text Formatting ⇒ Reducing some text width in exam class

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm

### Reducing some text width in exam class

Is there a way (surely there is!) to reduce the width of text and give more space to an answer line on the right part, in this MWE code ? (sorry for the idiotic questions in this example, but I couldn't resist and didn't found anything better in a quick rush! )

\documentclass[11pt]{exam}\usepackage[T1]{fontenc}\usepackage{amsmath}\usepackage[margin=1in]{geometry}\begin{document}\begin{questions}\question[10] Some true or false questions to answer very quick : \medskip \begin{parts}	\setlength{\rightmargin}{1in}%	\part Is it true that this sentence is false ?	\hfill\makebox[0.5in]{\dotfill}	\smallskip	\part Your name is the same as what it was ten thousands of years ago. \hfill\makebox[0.5in]{\dotfill}	\smallskip	\part This is a long, very long, sentence that means absolutely nothing, and is here to piss you off and to bore you to death.	\hfill\makebox[0.5in]{\dotfill}	\smallskip	\part This is a true-false question which doesn't have any true of false answer, just to annoy you like hell.  Geez this exam is dull !	\hfill\makebox[0.5in]{\dotfill}\end{parts}\end{questions}\end{document}

Preview :
exam.jpg (34.54 KiB) Viewed 227 times

As you can see in this very hilarious example ( ), the dotted lines aren't properly aligned, and there isn't enough space above them. How can I reduce the length of text, and get more space for the answer dotted lines ?

Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm
Now, I'm really at lost with this. Any idea how to solve the issue described above?

Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm
Using the command \newline may solve my issue, but if feels a bit hacky to me :
\documentclass[11pt]{exam}\usepackage[T1]{fontenc}\usepackage{amsmath}\usepackage[margin=1in]{geometry}\begin{document}\begin{questions}\question[10] Some true or false questions to answer very quick : \medskip \begin{parts}	\setlength{\rightmargin}{1in}%	\part Is it true that this sentence is false ?	\hfill\makebox[0.5in]{\dotfill}	\smallskip	\part Your name is the same as what it was ten thousands of years ago. \hfill\makebox[0.5in]{\dotfill}	\smallskip	\part This is a long, very long, sentence that means absolutely nothing, and is \newline here to amuse you to death.	\hfill\makebox[0.5in]{\dotfill}	\smallskip	\part This is a true-false question which doesn't have any true of false answer, \newline just to annoy you like hell.  Geez this exam is dull !	\hfill\makebox[0.5in]{\dotfill}\end{parts} \end{questions}\end{document}

And why is the last dotted line not properly aligned with the other lines ? I have to add \smallskip to fix this.

Stefan Kottwitz
Posts: 8871
Joined: Mon Mar 10, 2008 9:44 pm
Hi Cham,

a line end is like a space. So above, you have a line end (space) and then a small skip, then a line end. In the last line there's no small skip, just a line end.

You can see it's aligned if you comment out the line end before the small skip:

\documentclass[11pt]{exam}\usepackage[T1]{fontenc}\usepackage{amsmath}\usepackage[margin=1in]{geometry}\begin{document}\begin{questions}\question[10] Some true or false questions to answer very quick : \medskip \begin{parts}	\setlength{\rightmargin}{1in}%	\part Is it true that this sentence is false ?	\hfill\makebox[0.5in]{\dotfill}%	\smallskip	\part Your name is the same as what it was ten thousands of years ago. \hfill\makebox[0.5in]{\dotfill}%	\smallskip	\part This is a long, very long, sentence that means absolutely nothing, and is \newline here to amuse you to death.	\hfill\makebox[0.5in]{\dotfill}%	\smallskip	\part This is a true-false question which doesn't have any true of false answer, \newline just to annoy you like hell.  Geez this exam is dull !	\hfill\makebox[0.5in]{\dotfill}%\end{parts} \end{questions}\end{document}

Stefan

Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm
Is there a simple way to reduce the text width, while keeping the answer slot on the right side (after the text), without using the \newline command ?

Stefan Kottwitz
Posts: 8871
Joined: Mon Mar 10, 2008 9:44 pm
You could use \parbox each time to limit the text width when needed.

\part \parbox[t]{0.6\textwidth}{This is a true-false question    which doesn't have any true of false answer, just to annoy you    like hell.  Geez this exam is dull !}    \hfill\parbox[b]{0.5in}{\dotfill}

Stefan

Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm
Wow, this is great ! Thanks a lot Stefan. Case is now solved.

Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm
Hmm, actually, there's a small annoying glitch : the dotted answer line is aligned with the first line of text, which isn't appropriate for this kind of questions. The answer line should be aligned with the last line of text inside the parbox. Is there a way to fix that ?

Stefan Kottwitz
Posts: 8871
Joined: Mon Mar 10, 2008 9:44 pm
I noticed this too. Normally I use the optional argument of \parbox for aligning (t, b or the default c). So I would choose b, but I already had to use [t] to align at the top at the left side. I could imagine setting an anchor and using a TikZ overlay for an aligned placement of the dots, but so it gets a bit complicated, perhaps you find a simpler way.

Stefan

Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm
Hmm, the solution appears to be trivial : just add a space before the answer line :

\documentclass[11pt]{exam}\usepackage[T1]{fontenc}\usepackage{amsmath}\usepackage[margin=1in]{geometry}\begin{document}\begin{questions}\question[10] Some true or false questions to answer very quick : \medskip \begin{parts}	\setlength{\rightmargin}{1in}%	\part \parbox[t]{0.8\textwidth}{Is it true that this sentence is false ?} 	\hfill\makebox[0.5in]{\dotfill}%	\part \parbox[t]{0.8\textwidth}{Your name is the same as what it was ten thousands of years ago.} 	\hfill\makebox[0.5in]{\dotfill}%	\part \parbox[t]{0.8\textwidth}{This is a long, very long, sentence that means absolutely nothing, and is here to amuse you to death.} 	\hfill\makebox[0.5in]{\dotfill}%	\part \parbox[t]{0.8\textwidth}{This is a true-false question which doesn't have any true of false answer, just to annoy you like hell.  Geez this exam is dull !} 	\hfill\makebox[0.5in]{\dotfill}%\end{parts} \end{questions}\end{document}

What do you think?

EDIT : The vertical spacings are a bit weird, though. I'm not sure yet this solution is appropriate.