LaTeX forum ⇒ Document ClassesBasic problem with the exam class Topic is solved

Information and discussion about specific document classes and how to create your own document classes.
User avatar
Cham
Posts: 816
Joined: Sat Apr 02, 2011 4:06 pm

Basic problem with the exam class

Postby Cham » Tue Oct 31, 2017 10:51 pm

I need to add a few comments before some questions, using the exam class. Here's a MWE showing my problem. What is wrong with this very basic code ?

  1. \documentclass[11pt]{exam}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[margin=1in]{geometry}
  4.  
  5. \begin{document}
  6.  
  7. \begin{questions}
  8.  
  9. A few questions to disturb you :
  10.  
  11. \question[2] Who's buried in Grant's tomb?
  12.  
  13. \answerline
  14.  
  15. A few more questions to annoy you :
  16.  
  17. \question[3] Which is heavier: A pound of feathers, or a pound of lead?
  18.  
  19. \answerline
  20.  
  21. \end{questions}
  22.  
  23. \end{document}


LaTeX gives me a couple of errors :
LaTeX Error: Something's wrong--perhaps a missing \item.


How can I add a few lines of text (comments) before some questions ? The comments are not part of the questions themselves.

Also, I would like to remove the points for some of the questions. Removing [2] for example gives an empty ().

User avatar
Stefan Kottwitz
Site Admin
Posts: 8529
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Wed Nov 01, 2017 1:35 am

Hi Cham!

The error occurs because \begin{questions} starts a list environment. So everything has to be an \item, \question makes an implicit \item.

Simply add non-question text right before \begin{questions}.

For having 0 points, I would clearly say \question[0] so (0 points) is visible. Otherwise it looks like forgotten, not stated. It would be more consistent.

Stefan
Site admin

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

Postby Cham » Wed Nov 01, 2017 1:39 am

Stefan, I need to not show the points at all for many questions.

Actually, I need to write a long list of about 25 questions, and each one have a 2 points value. I don't want to repeat the 2 points on each question. Just stating the points at the comment level (before the question) would be enough and better looking.

User avatar
Stefan Kottwitz
Site Admin
Posts: 8529
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Wed Nov 01, 2017 1:49 am

You canard these commands to your preamble and use them:

  1. \newcommand*{\hidepoints}{\pointsinmargin\pointformat{}}
  2. \newcommand*{\showpoints}{\nopointsinmargin\pointformat{(\thepoints)}}
  3. ...
  4. \begin{questions}
  5. \question[2] Who's buried in Grant's tomb?
  6. \answerline
  7. \hidepoints
  8. A few more questions to annoy you :
  9. \question[2] Which is heavier: A pound of feathers, or a pound of lead?
  10. \showpoints
  11. \question[23] One more
  12. \answerline
  13. \end{questions}


Stefan
Site admin

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

Postby Cham » Wed Nov 01, 2017 1:51 am

Here's what I'm trying to do (text in French, but this is irrelevent) :
test.jpg
test.jpg (36.95 KiB) Viewed 144 times


It's a long list of multiple choices questions, followed by a list of True/False questions. There's a comment between the first list and the second list (T/F), and yet the numbers should follow in a logical way.

How would you do this ?

PS. I'll try your suggestion above...

User avatar
Stefan Kottwitz
Site Admin
Posts: 8529
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Wed Nov 01, 2017 1:54 am

I would use the exam manual as the base to do that. I normally don't use this class myself. I guess the manual helps, and if there's something to modify or to hack, let us know. ;-)

Stefan
Site admin

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

Postby Cham » Wed Nov 01, 2017 2:01 am

For this exam, I would like to completely remove the points for all the questions. The points would be stated separately in a comment, before each list of questions (multiple choices, true/false, and some development questions),

I don't see the option/command to remove all the points, in the manual.

User avatar
Stefan Kottwitz
Site Admin
Posts: 8529
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Wed Nov 01, 2017 3:06 am

In that case you could use \pointsinmargin\pointformat{} as above. Specifically, \pointformat{} makes the formatting being empty, the other command if for avoiding the unnecessary indentation then.

Stefan
Site admin

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

Postby Cham » Wed Nov 01, 2017 4:07 am

It's working great ! Thanks a lot !

Now, how could we slide the \answerline line to the left, and remove its number ? Or to define a left side answer rule ?

I also need to customize the symbols in the choices list. By default, they are capitalized letters (A, B, C, ...). I would prefer simple integers, or small letters instead. The documentation doesn't seem to show how to change this.

User avatar
Stefan Kottwitz
Site Admin
Posts: 8529
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Wed Nov 01, 2017 4:18 am

Do you have a current good-looking example to test? I lost the one I worked it when my computer crashed right now. :-o

Maybe also Clemes jumps in, a moderator from latex.org, he is the author of the exsheets package and its successor xsim. Just to give you new ideas. ;-)

Stefan
Site admin


Return to “Document Classes”

Who is online

Users browsing this forum: No registered users and 1 guest