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: 894
Joined: Sat Apr 02, 2011 4:06 pm

Reducing some text width in exam class

Postby Cham » Sun May 20, 2018 4:21 pm

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! :oops: )

  1. \documentclass[11pt]{exam}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{amsmath}
  4. \usepackage[margin=1in]{geometry}
  5. \begin{document}
  6. \begin{questions}
  7. \question[10] Some true or false questions to answer very quick :
  8.  
  9. \medskip
  10.  
  11. \begin{parts}
  12. \setlength{\rightmargin}{1in}%
  13. \part Is it true that this sentence is false ?
  14. \hfill\makebox[0.5in]{\dotfill}
  15. \smallskip
  16. \part Your name is the same as what it was ten thousands of years ago. \hfill\makebox[0.5in]{\dotfill}
  17. \smallskip
  18. \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.
  19. \hfill\makebox[0.5in]{\dotfill}
  20. \smallskip
  21. \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 !
  22. \hfill\makebox[0.5in]{\dotfill}
  23. \end{parts}
  24. \end{questions}
  25. \end{document}


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


As you can see in this very hilarious example ( :roll: ), 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 ?

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

Postby Cham » Sun May 20, 2018 7:05 pm

Now, I'm really at lost with this. Any idea how to solve the issue described above? :?:

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

Postby Cham » Mon May 21, 2018 3:22 am

Using the command \newline may solve my issue, but if feels a bit hacky to me :
  1. \documentclass[11pt]{exam}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{amsmath}
  4. \usepackage[margin=1in]{geometry}
  5. \begin{document}
  6. \begin{questions}
  7. \question[10] Some true or false questions to answer very quick :
  8.  
  9. \medskip
  10.  
  11. \begin{parts}
  12. \setlength{\rightmargin}{1in}%
  13. \part Is it true that this sentence is false ?
  14. \hfill\makebox[0.5in]{\dotfill}
  15. \smallskip
  16. \part Your name is the same as what it was ten thousands of years ago. \hfill\makebox[0.5in]{\dotfill}
  17. \smallskip
  18. \part This is a long, very long, sentence that means absolutely nothing, and is \newline here to amuse you to death.
  19. \hfill\makebox[0.5in]{\dotfill}
  20. \smallskip
  21. \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 !
  22. \hfill\makebox[0.5in]{\dotfill}
  23. \end{parts}
  24.  
  25. \end{questions}
  26. \end{document}


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

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

Postby Stefan Kottwitz » Tue May 22, 2018 1:53 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:

  1. \documentclass[11pt]{exam}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{amsmath}
  4. \usepackage[margin=1in]{geometry}
  5. \begin{document}
  6. \begin{questions}
  7. \question[10] Some true or false questions to answer very quick :
  8.  
  9. \medskip
  10.  
  11. \begin{parts}
  12. \setlength{\rightmargin}{1in}%
  13. \part Is it true that this sentence is false ?
  14. \hfill\makebox[0.5in]{\dotfill}%
  15. \smallskip
  16. \part Your name is the same as what it was ten thousands of years ago. \hfill\makebox[0.5in]{\dotfill}%
  17. \smallskip
  18. \part This is a long, very long, sentence that means absolutely nothing, and is \newline here to amuse you to death.
  19. \hfill\makebox[0.5in]{\dotfill}%
  20. \smallskip
  21. \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 !
  22. \hfill\makebox[0.5in]{\dotfill}%
  23. \end{parts}
  24.  
  25. \end{questions}
  26. \end{document}


Stefan
Site admin

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

Postby Cham » Tue May 22, 2018 2:11 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 ?

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

Postby Stefan Kottwitz » Tue May 22, 2018 3:25 pm

You could use \parbox each time to limit the text width when needed.

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


Stefan
Site admin

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

Postby Cham » Tue May 22, 2018 4:54 pm

Wow, this is great ! Thanks a lot Stefan. Case is now solved. :)

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

Postby Cham » Tue May 22, 2018 5:32 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 ?

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

Postby Stefan Kottwitz » Tue May 22, 2018 5:39 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
Site admin

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

Postby Cham » Tue May 22, 2018 5:51 pm

Hmm, the solution appears to be trivial : just add a space before the answer line :

  1. \documentclass[11pt]{exam}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{amsmath}
  4. \usepackage[margin=1in]{geometry}
  5. \begin{document}
  6. \begin{questions}
  7. \question[10] Some true or false questions to answer very quick :
  8.  
  9. \medskip
  10.  
  11. \begin{parts}
  12. \setlength{\rightmargin}{1in}%
  13. \part \parbox[t]{0.8\textwidth}{Is it true that this sentence is false ?}
  14.  
  15. \hfill\makebox[0.5in]{\dotfill}%
  16. \part \parbox[t]{0.8\textwidth}{Your name is the same as what it was ten thousands of years ago.}
  17.  
  18. \hfill\makebox[0.5in]{\dotfill}%
  19. \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.}
  20.  
  21. \hfill\makebox[0.5in]{\dotfill}%
  22. \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 !}
  23.  
  24. \hfill\makebox[0.5in]{\dotfill}%
  25. \end{parts}
  26.  
  27. \end{questions}
  28. \end{document}


What do you think?

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


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 4 guests