0

I have an enumerated list of math exercises in Beamer. I also have an enumerated list of answers to the math exercises in the last frame(s) of my document.

I would like to link each question to its answer in such a way that if I remove an exercise, or reorder the exercises, the list of answers is still synchronized with the list of exercises.

Is there a way to accomplish this?

1
  • Welcome to TeX.SX!! Please give a full minimal working example. Currently we have to guess what packages etc you are using and this makes it really hard to help you. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem. This makes it much easier for people to help you --- and much more likely that they will!
    – user30471
    Sep 9, 2016 at 3:36

1 Answer 1

1

How about something like this, using expl3 to create some functions to store the questions and answers for later use. They can then be printed whenever you want.

I used an article-documentclass here, but I think this would work for beamer too.

Output

enter image description here

Code

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\seq_new:N \l_user_Q_seq
\seq_new:N \l_user_A_seq
\NewDocumentCommand{\addQA}{mm}{%
  % #1: Question
  % #2: Answer
   \seq_put_right:Nn \l_user_Q_seq {#1}
   \seq_put_right:Nn \l_user_A_seq {#2}
}
\newcommand{\printQ}{%
\section*{Questions}
\begin{enumerate}
  \seq_map_inline:Nn \l_user_Q_seq {\item ##1}
\end{enumerate}
}
\newcommand{\printA}{%
\section*{Answers}
\begin{enumerate}
  \seq_map_inline:Nn \l_user_A_seq {\item ##1}
\end{enumerate}
}
\ExplSyntaxOff


\begin{document}


\addQA{%
  How much wood could a woodchuck chuck if a woodchuck could chuck wood?%
  }{%
  A woodchuck would chuck as much wood as a woodchuck would if a woodchuck could chuck wood.}
\addQA{%
  How many ducks are there on \texttt{tex.stackexchange}?
  }{%
  Input needed from experts in the field. }

\printQ
\printA

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .