LaTeX forum ⇒ Text FormattingReducing some text width in exam class

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

Reducing some text width in exam class

Postby Cham » Wed May 23, 2018 3:36 pm

Stefan, I need some opinion on this solution. Adding \vspace{-1ex} gives some nice output, but I'm not even sure to understand what I'm doing here! :oops:

  1. \documentclass[11pt]{exam}
  2. \begin{document}
  3. \begin{questions}
  4. \question[10] Some true or false questions to answer very quickly, without thinking :
  5.  
  6. \medskip
  7.  
  8. \begin{parts}
  9. \part \parbox[t]{0.8\textwidth}{Is it true that this sentence is false ?}
  10.  
  11. \vspace{-1ex}\hfill\makebox[0.5in]{\dotfill}%
  12. \smallskip
  13. \part \parbox[t]{0.8\textwidth}{Your name is the same as what it was ten thousands of years ago.}
  14.  
  15. \vspace{-1ex}\hfill\makebox[0.5in]{\dotfill}%
  16. \smallskip
  17. \part \parbox[t]{0.8\textwidth}{This is a long, very long and boring sentence that means absolutely nothing, and is here to amuse you.}
  18.  
  19. \vspace{-1ex}\hfill\makebox[0.5in]{\dotfill}%
  20. \smallskip
  21. \part \parbox[t]{0.8\textwidth}{This is a true-false question which doesn't have any true or false answer, just to annoy you like hell. Failing this kind of exam is fun!}
  22.  
  23. \vspace{-1ex}\hfill\makebox[0.5in]{\dotfill}%
  24. \end{parts}
  25.  
  26. \end{questions}
  27. \end{document}

User avatar
Stefan Kottwitz
Site Admin
Posts: 8907
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Wed May 23, 2018 4:01 pm

Here's a way: it puts a parbox with the needed height, and the dots in the last line:

  1. \documentclass[11pt]{exam}
  2. \begin{document}
  3. \begin{questions}
  4. \question[10] Some true or false questions to answer very quickly, without thinking :
  5.  
  6. \medskip
  7.  
  8. \newcommand{\linedots}[2][1]{%
  9. \hfill\parbox[t][#1\baselineskip][t]{0.5in}{#2\mbox{}\dotfill}}
  10. \newcommand{\onelinedots}{\linedots{}}
  11. \newcommand{\twolinedots}{\linedots[2]{\mbox{}\\}}
  12. \newcommand{\threelinedots}{\linedots[3]{\mbox{}\\\mbox{}\\}}
  13.  
  14. \begin{parts}
  15. \part \parbox[t]{0.8\textwidth}{Is it true that this sentence is false ?}
  16. \onelinedots
  17.  
  18. \part \parbox[t]{0.8\textwidth}{This is a long, very long and boring sentence that means absolutely nothing, and is here to amuse you.}
  19. \twolinedots
  20.  
  21. \part \parbox[t]{0.8\textwidth}{This is a true-false question which doesn't have any true or false answer, just to annoy you like hell. Failing this kind of exam is fun! Believe it or not - this is for filling three lines, the third one nearly up to the end.}
  22. \threelinedots%
  23. \end{parts}
  24.  
  25. \end{questions}
  26. \end{document}


Stefam
Site admin

User avatar
Cham
Posts: 885
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Wed May 23, 2018 4:51 pm

That's a bit complicated for my taste. How to achieve a similar result, manually (without using a macro)?

Or how to change the \vspace{-1ex} that I used above, so the answer line is well aligned with the last line of text?

User avatar
Stefan Kottwitz
Site Admin
Posts: 8907
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Wed May 23, 2018 5:06 pm

I used the macro to simplify things in the document itself. In the text, it looks pretty clear.

Stefan
Site admin

User avatar
Cham
Posts: 885
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Wed May 23, 2018 6:18 pm

Well, I would like to know how to do the same manually, without the macros. It's not clear to me how the macro is working. And in some cases, I may even have some longer text (that would be very rare, though).

Or in other words : how can I change my use of \vspace{-1ex} so the answer line is properly aligned with the last line of text?


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 4 guests