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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to rename or "copy" the enumerate environment twice in order to have two different named enumerate environments. E.g.

\begin{questions}
   \item lorem ipsum
   \item lorem ipsum
\end{questions}

\begin{answers}
   \item lorem ipsum
   \item lorem ipsum
\end{answers}
share|improve this question
    
Hello, try to look the ctan.org/pkg/enumitem package – flav Jan 5 at 12:56
3  
Can you specify what you want to achieve? Please show an example case where you'd use these new lists/environments. – Alenanno Jan 5 at 13:03
2  
Your sample text suggests that you want to keep questions and answers together in your source. That's a good idea. The answers package is designed for that - you might want to take a look. – Ethan Bolker Jan 5 at 13:31
up vote 9 down vote accepted

Edit: Questionnaire time!

This solution sets a new command called \qanda, a modified version of this post by cgnieder and this question for placing a title.

The new command takes two arguments, but inside of each argument we have a potentially infinite list, so in the first argument you'll write the questions, while in the second one the answers, obviously in the same order.

Additionally the answers' list has been rotated but you can do what you want with it. Here's the output:

enter image description here

And here's the code:

\documentclass{article}
\usepackage{enumitem}
\usepackage{xparse}
\usepackage{rotating}

\setlist[enumerate]{itemsep=-1mm}

\NewDocumentCommand\qanda{>{\SplitList{;}}m>{\SplitList{;}}m}
  {
\paragraph{Questions:}
    \begin{enumerate}
      \ProcessList{#1}{ \insertq }
    \end{enumerate}
\vspace{2cm}
\begin{turn}{180}
\begin{minipage}{\textwidth}
\paragraph{Answers:}
    \begin{enumerate}
      \ProcessList{#2}{ \inserta }
    \end{enumerate}
\end{minipage}
\end{turn}
  }
\newcommand\insertq[1]{\item #1}
\newcommand\inserta[1]{\item #1}

\begin{document}

\section*{Questionnaire}

And now some questions and (rotated) answers.

\qanda{% Questions
    What's the name of our star?;
    What planet comes after the Earth?}%
    {% Answers
    Sun;%
    Mars}%

\end{document}

Original answer

enter image description here

\documentclass{article}
\usepackage{enumitem}

\newlist{questions}{enumerate}{3}
\setlist[questions]{label=\arabic*.}

\newlist{answers}{enumerate}{3}
\setlist[answers]{label=\arabic*.}

\begin{document}
\begin{questions}
   \item lorem ipsum
   \item lorem ipsum
\end{questions}

\begin{answers}
   \item lorem ipsum
   \item lorem ipsum
\end{answers}
\end{document} 
share|improve this answer

There are four ways how to copy an environment:

  1. Using low-level copy. This is a true copy in the TeX's sense, but it's a non-LaTeXy solution. The environment answers is now independent from any re-definition of questions.

    \let\answers\questions
    \let\endanswers\endquestions
    
  2. Using slightly higher-level copy. If questions is re-defined, so is answers automatically.

    \newenvironment{answers}{\questions}{\endquestions}
    
  3. Using proper LaTeX groups too. Same as the previous, but an extra level of unnecessary grouping is added. I wouldn't recommend it.

    \newenvironment{answers}{%
      \begin{questions}%
    }{%
      \end{questions}%
    }
    
  4. Defining the environment from scratch. If you define questions, you can define answers the same way:

    \newenvironment{questions}{BLA}{BLABLA}
    \newenvironment{answers}{BLA}{BLABLA}
    

    Or in case of environments defined by a special command, for instance:

    \newtheorem{questions}{BLA}
    \newtheorem{answers}{BLA}
    

Use the one which is most suitable for the task.

share|improve this answer

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.