Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

(I'll preface this question by saying that there seem to be quite a few question on tex.se with keywords 'align' and 'enumerate', but it seems as if they all deal with questions regarding alignment within the enumerate environment or combining the the align and enumerate environments - so I don't believe that my question is redundant.)

Here's the gist of what I am doing and what issue has come about. I am typing up solutions to a, say, three-part (math) question, the parts being enumerated as (i),(ii), and (iii). After stating each part, I wish to write the solution right underneath. So it should look like

(i) Q

A

(ii) Q

A

(iii) Q

A

Perhaps it's not the most efficient way of typing it up (by all means, feel free to recommend something else) but I've done this as

\begin{enumerate}[(i)]
\item question 1
\end{enumerate}
answer 1

\begin{enumerate}[(ii)]
\item question 2
\end{enumerate}
answer 2

\begin{enumerate}[(iii)]
\item question 3
\end{enumerate}
answer 3

However, the way it comes out has (iii) shifted further right than (ii), which is shifted further right than (i). Can anyone tell me why this happens and how to remedy it?

share|improve this question
    
For numerical lists, see How to make enumerate items align at left margin? –  Werner Sep 19 '12 at 0:00

3 Answers 3

up vote 9 down vote accepted

One option is to define a new environment (or maybe command) for the questions:

\documentclass{article}

\newcounter{question}
\newenvironment{question}
  {\stepcounter{question}\par\vspace{\topsep}\makebox[2em]{(\roman{question})\hfill}}
  {\par\vspace{\topsep}}

\begin{document}

\begin{question}
question 1
\end{question}
answer 1

\begin{question}
question 2
\end{question}
answer 2

\begin{question}
question 3
\end{question}
answer 3

\end{document}

enter image description here

Another option using a theorem-like structure (a list) though the amsthm package:

\documentclass{article}
\usepackage{amsthm}

\newtheoremstyle{question}
  {3pt}{3pt}{\normalfont}
  {}{\bfseries}{}{.5em}
  {#1\makebox[2em]{(#2)\hfill}#3}%

\theoremstyle{question}
\newtheorem{question}{}
\renewcommand\thequestion{\roman{question}}

\begin{document}

\begin{question}
question 1
\end{question}
answer 1

\begin{question}
question 2
\end{question}
answer 2

\begin{question}
question 3
\end{question}
answer 3

\end{document}

enter image description here

share|improve this answer
    
Thank you very much. I've gone with your first suggestion. –  JSeaton Sep 19 '12 at 0:52

I suggest the exam document class because allow enumerate questions (in roman also) with the correct indentation of answers (see i-iv in the MWE) or the alignment with the left margin (v-vi in the MWE), but also many other interesting options for questions, as print with/without answers, show/hide points, etc. The package in CTAN have a large but comprehensible manual

\documentclass[answers,12pt,addpoints]{exam}
\usepackage{xcolor}
\definecolor{SolutionColor}{rgb}{0.1,0.3,1}
\usepackage{lipsum}

\renewcommand{\thequestion}{\roman{question}}
\renewcommand\questionlabel{\llap{(\thequestion)}}

\begin{document}

\pointsinrightmargin
\boxedpoints
% \unframedsolutions
\shadedsolutions
\definecolor{SolutionColor}{rgb}{0.9,0.9,1}

\begin{questions}

\question[10] What is the exam class?
\begin{solution}
This is the solution
\end{solution}

\renewcommand{\solutiontitle}{}

\question[5]  Do you know the addpoints option?
\begin{solution}
This is the solution without label
\end{solution}

\renewcommand{\solutiontitle}{\noindent\textbf{Answer: }\par\noindent}


\question[10] Why is there air?
\begin{solution}
This is the solution with another label
\end{solution}

\question[15] How much wood would a woodchuck 
chuck if a woodchuck could chuck wood?
\begin{solution}
This is the solution
\end{solution}


\question[10] Compute $\displaystyle\int_0^1 x^2 \, dx$.

\begin{EnvFullwidth}
\begin{solution}
This is a WIDER solution %dummy solution
\end{solution}
\end{EnvFullwidth}

\bonusquestion[1] On what day of the week did he do it?

\renewcommand{\solutiontitle}{\noindent\textbf{Answer: }\par\noindent}

\begin{EnvFullwidth}
\begin{solution}
\lipsum[2]%dummy text
\end{solution}
\end{EnvFullwidth}

\end{questions}

\begin{center}

This exam has \numquestions\ questions, for a total 
of \numpoints\ points and \numbonuspoints\ bonus points.
\end{center}


\end{document}

enter image description here

share|improve this answer
    
unfortunately, with this approach the words "Why" and "How" (on questions iii and iv) do not line up with the "What" of question i, and that is what the original question asked to be fixed. also, the period after the parenthesized question numbers isn't really good style. –  barbara beeton Sep 24 '12 at 14:11
    
@barbarabeeton, Hmm ... (cleaning glasess) It's true!. The \thequestion can be safely redefined as roman counter but adding parenthesis need some alignment (\llap for example). I agree also that with the parentheses should not be a period. This force also touch \questionlabel (although I prefer the period without the parentheses: simpler but mostly cleaner). Now both issues fixed in the answer. –  Fran Sep 24 '12 at 22:46

I would recommend using the enumitem package, and it's resume* feature which gives you the desired alignment of the question labels:

enter image description here

Notes:

  • You could also use \newlist to define your own list style.

Code:

\documentclass{article}

\usepackage{enumitem}

\begin{document}

\begin{enumerate}[label={(\roman*)},series=Questions]
\item question 1
\end{enumerate}
answer 1

\begin{enumerate}[resume*=Questions]
\item question 2
\end{enumerate}
answer 2

\begin{enumerate}[resume*=Questions]
\item question 3
\end{enumerate}
answer 3
\end{document}

If you also want the answers to be aligned on the left to the start of the question you can simply place the answer within the enumerate's \item:

enter image description here

Code:

\documentclass{article}

\usepackage{enumitem}

\begin{document}

\begin{enumerate}[label={(\roman*)},series=Questions]
\item question 1

answer 1
\end{enumerate}


\begin{enumerate}[resume*=Questions]
\item question 2

answer 2
\end{enumerate}


\begin{enumerate}[resume*=Questions]
\item question 3

answer 3
\end{enumerate}
\end{document}
share|improve this answer
    
Thank you for the response, Peter. +1. –  JSeaton Sep 19 '12 at 0:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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