I am trying to create a new environment for multiple choice test questions. I want to make sure that every question has a number and has a constant indentation:

1.  Lorem ipsum
    dolor sit amet.
    Lorem ipsum
    dolor sit amet.

2.  Lorem ipsum
    dolor sit amet.
    Lorem ipsum
    dolor sit amet.

I think I should use a minipage for each question in the environment definition. But I don't know how to adjust the spacing so that each question body is aligned. What should I use for the numbers?

Edit: I'm attaching my working example. Down below is a portion of the latex.ltx file, with enumerate modified to cnumerate to prevent name clashes. I basically want to create an independent environment like the equation or tabular. Just assume that \begin{question} \item Lorem. \end{question} is to create a single indented item with a number.

Why does cnumerate not print numbers? The indentation is fine, but there is no numbers. I print \thecnumi for each item, and it works, but the numbers do not show up in the labels.


          [1999/03/05 v3.00 cnumerate extcnsions (DPC)]

% latex.ltx

\newcount\@cnumdepth \@cnumdepth = 0
  \ifnum \@cnumdepth >\thr@@\@toodeep\else
        \csname label\@cnumctr\endcsname
\let\endcnumerate =\endlist

the main file, doc.tex

\item Lorem ipsum.
  • 1
    Welcome to TeX.SE. – Peter Grill Oct 25 '12 at 18:54
  • As an aside, might I recommend the exam document class? It's a lot easier for things like this. If you need custom question numbers (not automagic), I've written a few macros for that. – Sean Allred Oct 25 '12 at 23:24
  • 1
    @vermiculus The exam class does exactly what I want, especially the multiple choice questions. I'm surprised I didn't come across that before. I am going to delve into the source code to make it suit my needs. Perhaps you could post your comment as an answer so I could mark it? – osolmaz Oct 26 '12 at 8:19

Might I suggest the exam document class?

Sample document:




\firstpagefootrule % Use a footer rule on the first page
\runningheadrule   % and so on
\runningfootrule   % and so on (note that this does not cancel out \firstpagefootrule

% define the header for the first page (left, center, right), and so on
\firstpageheader{MATH 351 -- Analysis}{\large \sc Fall 2012 Midterm}{\today}
\firstpagefooter{}{\thepage\ of \numpages}{}
\runningheader{MATH 351 -- Analysis}{Fall 2012 Midterm}{\today}
\runningfooter{}{\thepage\ of \numpages}{}

Read each question carefully. % Preliminary instructions
    \question[50] How long should a man's legs be? % This question is worth 50 points
        \begin{solutionorlines}[1in] % If \printanswers is specified,
                                     % the solution will be printed.
                                     % Otherwise, a box 1 inch tall
                                     % will be printed instead.
            Long enough to reach the ground!
    \question[$\infty$] \lipsum[1]   % arbitrary symbolic point values
        \int_0^{2\pi} \sin x\ \mathbf{d}x
            \int_0^{2\pi} \sin x\ \mathbf{d}x = 0
\uplevel{\lipsum[1-2]} % Perhaps a different part of the exam? More instructions?
    \question \lipsum[4]
            \part[10] \lipsum[5]
            \part[15] \lipsum[6]

produces a document with space left for the answers, while adding \printanswers to the preamble will produce the same document, but with the answers printed. If you would like custom question labels (instead of simply incremental), I've written a few new commands for that:

% for the `exam` class
    % Set the questionlabel to the user's choice
    \question % do the question thing
    % and reset it back to default
    % Set the partlabel to the user's choice
    \part % do the part thing
    % and reset it back to default

As always, complete documentation for the document class lives on CTAN.

Hope this helps!

|improve this answer|||||

I think in this instance (considering your output) it is easiest to use a standard enumerate environment. Possible alignment or counter formatting/cross-referencing could be manipulated/changed using enumitem, if/as needed:

enter image description here

\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
  \item \lipsum[1-2]
  \item \lipsum[3-4]
  \item \lipsum[5-6]

lipsum provided some dummy text in paragraph form, Lorem ipsum style.


  1. Easily modifiable via enumitem;
  2. Breaks across page boundaries; and
  3. Standard interface/usage.

For a global take an a specially-created environment question that emulates/clones enumerate, enumitem's interface provides:

\newlist{question}{enumerate}{3}% Clone enumerate as question environment (depth of 3)
\setlist[question]{label=\arabic*.}% All labels are "\arabic."

Now you can use

  \item \lipsum[1-2]
  \item \lipsum[3-4]
  \item \lipsum[5-6]

For more detail, see the enumitem documentation (section 7 Cloning the basic lists, p 10).

|improve this answer|||||
  • I've considered using enumerate, but what I want is more complicated: Create a new environment question which has its own contextual syntax, like a tabular environment. You know, like {c c c}. I wanted to borrow from the enumerate package and located enumerate.sty, but it was just recently and I didn't have time to understand any of that TeX code. Enumerate has a TeX definition instead of a LaTeX one. Do you have any suggestions on how to clone the definition of enumerate to provide for my needs? – osolmaz Oct 25 '12 at 18:38
  • @cgnieder I am aiming at writing a standalone class with many features. I need to build from the lowest level, so I tried copying and reverse-engineering enumerate.sty. I now need to find where enumdepth and enumi are defined, because they are not in the sty file. Do you have any suggestions? – osolmaz Oct 25 '12 at 18:54
  • @OnurSolmaz: It is difficult to provide a more appropriate answer without having details as to what you want to do. Best way to do that would be to It would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. At least as far as you can take it. Then you can ask specific questions about it which could be more directly addressed. – Peter Grill Oct 25 '12 at 19:20
  • @PeterGrill I isolated the enumerate environment from the files base/latex.ltx and tools/enumerate.sty. However, when I use the environment, it compiles but does not show the numbers. How and where can I attach the code, as a MWE? – osolmaz Oct 25 '12 at 19:57
  • @OnurSolmaz: You should edit your original post and append/insert the code. Why does the enumitem solution not seem satisfactory? I don't understand. Is it because you want it to be "stand alone" and not depend on anything else? – Werner Oct 25 '12 at 20:02

I've found out that each class defines its own style enumeration labels. So I borrowed from article and modified for cnumerate. Adding the following to cnumerate.sty solves the problem. Also, the choices environment from the exam does something similar to what I need, and can be modified accordingly.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.