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.

This question is related to "How to interrupt-resume a list in latex". I am making an exam for my students and I want to use the multicols environment for various portions of the test.

  • The problem is, when I put the \begin{enumerate}[resume] inside the \begin{multicols}{2} environment, the list numbering does not properly resume.

Outside the multicols environment, the list resumes fine as in source provided above.

See example code:

\documentclass[10pt]{article}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage{setspace}
\usepackage{enumitem}
\usepackage{multicol}

%SET MARGINS (AND PAGE DIMENSIONS)
\usepackage[includeheadfoot,head=30pt,foot=30pt,top=1cm,bottom=1cm,left=1cm,right=1cm]{geometry}




%MULTIPLE COLUMNS
\usepackage{multicol}


%CUSTOM COMMANDS FOR INSTRUCTIONS, QUESTIONS, ANSWERS
\newcommand{\instructions}[1]{%
\colorbox{gray!20}{
\noindent\par
\noindent\makebox[\textwidth][l]{%
\begin{minipage}[t]{\linewidth}%1
  %\centering
  #1
\end{minipage}}
}}%
\newcommand{\question}[1]{\item #1}
%\newcommand{\answer}[1]{\textcolor{black}{\textbf{\small(Answer: #1)}}}%SHOW ANSWERS
\newcommand{\answer}[1]{\\\rule{4cm}{0.1pt}}%HIDE ANSWERS, BUT UNDERLINE
\newcommand{\fillin}[1]{\rule{4cm}{0.1pt}}



%CUSTOMIZE SECTIONS
\usepackage[]{titlesec}

\titleformat{name=\section}[block]
  {\Large\bfseries\sffamily}
  {}
  {0pt}
  {\colorsection}
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip}
\renewcommand{\thesection}{\Alph{section}}
\newcommand{\colorsection}[1]{%
  \colorbox{black}{\parbox[][1cm][b]{\dimexpr.3\textwidth-2\fboxsep}{\color{white}Part \thesection: \ #1}}}


%CUSTOM COLUMNS
\setlength{\columnsep}{1.5cm}% Column separation of text
 \parindent=0pt 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      BEGIN DOCUMENT
\begin{document}

\instructions{Fill in the blank}
\begin{multicols}{2}
\begin{enumerate}
\question{Do you prefer the modern \fillin{Ballet} to the classical.}
\question{There is a useful \fillin{bibliography} at the end of each chapter.}
\question{The photograph was \fillin{blurred} and it was hard to recognize him at first.}
\question{They \fillin{bowdlerized} the film by cutting out all the nude scenes.}
\end{enumerate}
\end{multicols}

\instructions{Write the word that matches the definition provided.}
\begin{multicols}{2}
\begin{enumerate}[resume]
\question{a long piece of cloth, often stretched between two poles, with a sign on it, usually carried by people taking part in a march.} \answer{banner}
\question{an important or exiting news story that is printed in one newspaper before any of the others know about it.} \answer{bathos}
\question{a file for holding papers, in which metal rings go through the holes in the edges of the pages, holding them in place.} \answer{binder / ring-binder}
\question{to give somebody all of the necessary information about a situation.} \answer{brief}
\question{the use of harsh-sounding words or phrases or a dicordant combination of sounds in music.}\answer{cacophony}% (opposite of euphony)
\question{insincere, specious language calculated to give the impression of piety and religious ferver. in critical writing the term is also used to signify the special language and phraseology  characteristic of a profession or art.}\answer{cant}
\question{The conclusion of a play, particularly a tragedy; It is the final stage in the falling action, ending the dramatic conflict, winding up the plot and consisting of the actions that result from the climax.}\answer{catastrophe}
\question{someone who likes films very much and considers them to be a form of art, not just entertainment.}\answer{cinephile}
\end{enumerate}
\end{multicols}


\end{document}
share|improve this question
1  
See the different solutions provided to tex.stackexchange.com/q/1669/15925. In particular, the issue of lists within other environments is discussed by Andrew Stacey. –  Andrew Swann Jan 10 '13 at 22:00
2  
Interestingly, your code works for me (with an old version of enumitem). But @AndrewSwann is right, the correct way to do this is tex.stackexchange.com/a/53108/21591, namely, the series key for enumerate of package enumitem. –  mafp Jan 10 '13 at 22:21
1  
I improved the answer a bit (some bits of your code weren't so precise as they should be), check it again please. –  tohecz Jan 10 '13 at 22:23
add comment

1 Answer 1

up vote 4 down vote accepted

The correct way to do it is to use the "series" option:

\begin{multicols}{2}
\begin{enumerate}[series=qa]
\question{Do you prefer the modern \fillin{Ballet} to the classical.}
\question{There is a useful \fillin{bibliography} at the end of each chapter.}
\question{The photograph was \fillin{blurred} and it was hard to recognize him at first.}
\question{They \fillin{bowdlerized} the film by cutting out all the nude scenes.}
\end{enumerate}
\end{multicols}

\instructions{Write the word that matches the definition provided.}
\begin{multicols}{2}
\begin{enumerate}[resume*=qa]
\question{a long piece of cloth, often stretched between two poles, with a sign on it, usually carried by people taking part in a march.} \answer{banner}
\question{an important or exiting news story that is printed in one newspaper before any of the others know about it.} \answer{bathos}
\question{a file for holding papers, in which metal rings go through the holes in the edges of the pages, holding them in place.} \answer{binder / ring-binder}
\question{to give somebody all of the necessary information about a situation.} \answer{brief}
\question{the use of harsh-sounding words or phrases or a dicordant combination of sounds in music.}\answer{cacophony}% (opposite of euphony)
\question{insincere, specious language calculated to give the impression of piety and religious ferver. in critical writing the term is also used to signify the special language and phraseology  characteristic of a profession or art.}\answer{cant}
\question{The conclusion of a play, particularly a tragedy; It is the final stage in the falling action, ending the dramatic conflict, winding up the plot and consisting of the actions that result from the climax.}\answer{catastrophe}
\question{someone who likes films very much and considers them to be a form of art, not just entertainment.}\answer{cinephile}
\end{enumerate}
\end{multicols}

In the sake of keeping the logical structure, you can define your own environment:

The following is the original answer and it possibly mal-behaving

However, it works with enumitem ver 2.x.

You need to modify the macro \enit@setresumekeys to do one declaration globally. Put this into your preamble after \usepackage{enumitem}:

\makeatletter
\def\enit@setresumekeys #1#2#3{%
  \enit@toks \expandafter {\enit@savekeys }%
  \xdef \enit@afterlist {#2\def \enit@noexcs {enit@resumekeys@#1}{\the\enit@toks }%
    \ifnum \enit@type =\z@ #3\gdef \enit@noexcs
      {enit@resume@#1}{\csname c@\@listctr \endcsname \the \csname c@\@listctr \endcsname }%
    \fi
  }%
}
\makeatother

In the original definiton of this macro, there's \def \enit@noexcs.

The full example:

\documentclass[10pt]{article}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage{setspace}
\usepackage{enumitem}
\usepackage{multicol}

\makeatletter
\def\enit@setresumekeys #1#2#3{%
  \enit@toks \expandafter {\enit@savekeys }%
  \xdef \enit@afterlist {#2\def \enit@noexcs {enit@resumekeys@#1}{\the\enit@toks }%
    \ifnum \enit@type =\z@ #3\gdef \enit@noexcs
    {enit@resume@#1}{\csname c@\@listctr \endcsname \the \csname c@\@listctr \endcsname }%
    \fi
  }%
}
\makeatother

%SET MARGINS (AND PAGE DIMENSIONS)
\usepackage[includeheadfoot,head=30pt,foot=30pt,top=1cm,bottom=1cm,left=1cm,right=1cm]{geometry}




%MULTIPLE COLUMNS
\usepackage{multicol}


%CUSTOM COMMANDS FOR INSTRUCTIONS, QUESTIONS, ANSWERS
\newcommand{\instructions}[1]{%
\colorbox{gray!20}{%
\makebox[\textwidth][l]{%
\begin{minipage}[t]{\linewidth}%1
  %\centering
  #1
\end{minipage}}%
}}%
\makeatletter
\newcommand{\question}[1]{\item #1}
%\newcommand{\answer}[1]{\textcolor{black}{\textbf{\small(Answer: #1)}}}%SHOW ANSWERS
\newcommand{\answer}[1]{\\\rule{4cm}{0.1pt}}%HIDE ANSWERS, BUT UNDERLINE
\newcommand{\fillin}[1]{\rule{4cm}{0.1pt}}



%CUSTOMIZE SECTIONS
\usepackage[]{titlesec}

\titleformat{name=\section}[block]
  {\Large\bfseries\sffamily}
  {}
  {0pt}
  {\colorsection}
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip}
\renewcommand{\thesection}{\Alph{section}}
\newcommand{\colorsection}[1]{%
  \colorbox{black}{\parbox[][1cm][b]{\dimexpr.3\textwidth-2\fboxsep}{\color{white}Part \thesection: \ #1}}}


%CUSTOM COLUMNS
\setlength{\columnsep}{1.5cm}% Column separation of text
 \parindent=0pt 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      BEGIN DOCUMENT
\begin{document}

\instructions{Fill in the blank}
\begin{multicols}{2}
\begin{enumerate}[resume]
\question{Do you prefer the modern \fillin{Ballet} to the classical.}
\question{There is a useful \fillin{bibliography} at the end of each chapter.}
\question{The photograph was \fillin{blurred} and it was hard to recognize him at first.}
\question{They \fillin{bowdlerized} the film by cutting out all the nude scenes.}
\end{enumerate}
\end{multicols}

\instructions{Write the word that matches the definition provided.}
\begin{multicols}{2}
\begin{enumerate}[resume]
\question{a long piece of cloth, often stretched between two poles, with a sign on it, usually carried by people taking part in a march.} \answer{banner}
\question{an important or exiting news story that is printed in one newspaper before any of the others know about it.} \answer{bathos}
\question{a file for holding papers, in which metal rings go through the holes in the edges of the pages, holding them in place.} \answer{binder / ring-binder}
\question{to give somebody all of the necessary information about a situation.} \answer{brief}
\question{the use of harsh-sounding words or phrases or a dicordant combination of sounds in music.}\answer{cacophony}% (opposite of euphony)
\question{insincere, specious language calculated to give the impression of piety and religious ferver. in critical writing the term is also used to signify the special language and phraseology  characteristic of a profession or art.}\answer{cant}
\question{The conclusion of a play, particularly a tragedy; It is the final stage in the falling action, ending the dramatic conflict, winding up the plot and consisting of the actions that result from the climax.}\answer{catastrophe}
\question{someone who likes films very much and considers them to be a form of art, not just entertainment.}\answer{cinephile}
\end{enumerate}
\end{multicols}


\end{document}

As David pointed out in the chat, the sequence \noindent\par\noindent has no effect inside a horizontal box (which \colorbox is). As well, I added two %s inside the definition of \instructions, to remove two spurious spaces it produced.

share|improve this answer
1  
The original version in enumitem is to protect nested enumerations, and their resumption, right? So this will break with your patch?! –  mafp Jan 10 '13 at 22:03
    
@mafp no, I just think that the package author didn't think of this possibility. Try the follwing code: chat.stackexchange.com/transcript/message/7620954#7620954 –  tohecz Jan 10 '13 at 22:10
1  
This patch is buggy because it could mess counters up if lists are used in floats. In other words, the assignment is local by design. As explained in some of the links above and in the docs, the proper way of doing "global resumes" is with the key series. –  Javier Bezos Jan 11 '13 at 9:57
1  
@JavierBezos Thanks! I didn't think of it this way, and I included the correct solution. –  tohecz Jan 11 '13 at 12:37
add comment

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.