5

I'm building a database of math puzzles that each TEX file gathers puzzles in one year such as 2017.tex may have 10 of them, each puzzle and its solution with a label.

Now I give talks and want to choose problems and solutions from these files now and then. Should I use \input and \chapter commands? I'm not using all the puzzles in one file and I don't want to write each puzzle as one TEX file. What is the best way to do this?

Thanks!!

1 Answers1

10

I made a package just for purposes like this. It's called exercisebank.

Say you have your 2017.tex, and in there you should have puzzles and solutions in the following format.

%% 2017.tex
%% Heads up! \end{solution} and \end{problem} can't have spaces in front of it and needs it's own line
\begin{problem}
  Puzzle 1 here
\end{problem}
\begin{solution}
  Solution 1 here
\end{solution}

\begin{problem}
  Puzzle 2 here
\end{problem}
\begin{solution}
  Solution 2 here
\end{solution}

Now you can do

\documentclass{article}
\usepackage{exercisebank}
% You might want no part problem headers (only Problem 1, Problem 2 etc), in that case: uncomment the line below:
% \exercisebanksetup{part problems=Off}
% To make a setup, you do this; \makeset{setupName}{puzzle-file}
% So to make a setup with all of the exercises from 2017:
\makeset{allof2017}{2017}
% Or you can cherry pick your favorites
\makeset{2017Favorites}{\select{2017}{1,2}}
\begin{document}
  % Then choose which to build
  \buildset{2017Favorites}
\end{document}

If you end up using this, please feel free to request features or report bugs here


Edit: I've now come across some other packages that do similar things. So I should also mention that e.g. xsim might also do what you want, and is probably more stable at this time. Furthermore, you could check out the exercise and exam topics on CTAN.