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?



1 Answer 1


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
  Puzzle 1 here
  Solution 1 here

  Puzzle 2 here
  Solution 2 here

Now you can do

% 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:
% Or you can cherry pick your favorites
  % Then choose which to build

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! Apr 5, 2018 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! Apr 5, 2018 at 9:44
  • Sure, I will expand my database first and wait for your next version. Thank you! Apr 5, 2018 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} Apr 8, 2018 at 19:31
  • How is it working for you, @HaoranChen Apr 13, 2018 at 6:53

You must log in to answer this question.

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