Document ClassesBasic problem with the exam class

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

Basic problem with the exam class

Post by Cham »

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 ?

Code: Select all

\documentclass[11pt]{exam}
\usepackage[T1]{fontenc}
\usepackage[margin=1in]{geometry}

\begin{document}

\begin{questions}

A few questions to disturb you :

\question[2] Who's buried in Grant's tomb?

\answerline

A few more questions to annoy you :

\question[3] Which is heavier: A pound of feathers, or a pound of lead?

\answerline

\end{questions}

\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 ().

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Basic problem with the exam class

Post by Stefan Kottwitz »

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
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Basic problem with the exam class

Post by Cham »

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: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Basic problem with the exam class

Post by Stefan Kottwitz »

You canard these commands to your preamble and use them:

Code: Select all

\newcommand*{\hidepoints}{\pointsinmargin\pointformat{}}
\newcommand*{\showpoints}{\nopointsinmargin\pointformat{(\thepoints)}}
...
\begin{questions}
\question[2] Who's buried in Grant's tomb?
\answerline
\hidepoints
A few more questions to annoy you :
\question[2] Which is heavier: A pound of feathers, or a pound of lead?
\showpoints
\question[23] One more
\answerline
\end{questions}
Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Basic problem with the exam class

Post by Cham »

Here's what I'm trying to do (text in French, but this is irrelevent) :
test.jpg
test.jpg (36.95 KiB) Viewed 10051 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: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Basic problem with the exam class

Post by Stefan Kottwitz »

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
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Basic problem with the exam class

Post by Cham »

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: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Basic problem with the exam class

Post by Stefan Kottwitz »

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
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Basic problem with the exam class

Post by Cham »

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: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Basic problem with the exam class

Post by Stefan Kottwitz »

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
LaTeX.org admin
Post Reply