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!!

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.

  • I made 3 TEX files and 2 of them have 2 puzzles each. When I make a setup using all the problems, it shows Problem 1 b), 2b) 2c) and 3b) 3c). Why? I am supposed that it shows Problem 1-5. Thanks! – Haoran Chen Apr 5 '18 at 9:33
  • This functionality is on the todo list and will be added in the next version. Probably some time this week or beginning of next week :) I’ll let you know! – Andreas Storvik Strauman Apr 5 '18 at 9:44
  • Sure, I will expand my database first and wait for your next version. Thank you! – Haoran Chen Apr 5 '18 at 9:46
  • I have pushed an update to CTAN. It'll probably be available on CTAN some time tomorrow, but TeXLive and MiKTeX might take a few more days. To convert part problems into normal problems you could just do \exercisebanksetup{part problems=Off} – Andreas Storvik Strauman Apr 8 '18 at 19:31
  • How is it working for you, @HaoranChen – Andreas Storvik Strauman Apr 13 '18 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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