I'm creating a problem set with a hint for each problem. I want to have the list of hints separated from the list of problems. Something like this:

Problem 1
Problem 2
Problem 3

Hint 1
Hint 2
Hint 3

There're gonna be 42 problems. I'm not sure about their order yet. I could simply create separate enviroments with counters for problems and hints. But then when I switch problems, I need to switch hints as well.

I'm just curious if it's possible to create such an enviroment that allows me to keep problem statement and hint together even if they will be rendered in different sections.

  • If you are using exam class, one can add extraneous materials using \fullwidth. Jun 2, 2017 at 2:03
  • It is a job for the answers package. Jun 2, 2017 at 2:42

1 Answer 1


A version with expl3, storing the problem and hint content in different property lists and extracting them later either in sequence or only a selected subset of it.

\DefineProblem{foo}[foo hint] will define the problem and its hint, \ProblemDisplay* will show all problems, \ProblemDisplay[select={1,3}] will show only problems 1 and 3. This fills the list of hints to be shown as well. Problems with no hints won't be shown.

Use \HintDisplay to display the hints later on.





\newtcolorbox[auto counter]{problembox}[1][]{colback=white,enhanced,sharp corners,colbacktitle={yellow},coltitle=black,title={Problem \thetcbcounter},#1}
\newtcolorbox{hintbox}[1][]{colback=white,enhanced,sharp corners,colbacktitle={green},coltitle=black,title={Hint \theprbcntr},#1}


\prop_new:N \g_patrik_problem_prop
\prop_new:N \g_patrik_hint_prop

\cs_generate_variant:Nn \prop_gput:Nnn {Nxn}

  \prop_gput:Nxn \g_patrik_problem_prop {defproblem\theprbdefcntr}{#2}
    \prop_gput:Nxn \g_patrik_hint_prop {hintproblem\theprbdefcntr}{#3}

\keys_define:nn {patrik} {
  select .code:n={\seq_set_from_clist:Nn \l_tmpa_seq {#1}},
  tcolorbox .code:n={\cs_set:Npn \localtcolorboxoptions {#1}}

  \cs_set:Npn \localtcolorboxoptions {}
  \keys_set:nn {patrik}{#2}
    \int_zero:N \l_tmpa_int
    \prop_map_inline:Nn \g_patrik_problem_prop {%
      \int_incr:N \l_tmpa_int
      \seq_gput_right:NV \g_patrik_display_seq {\l_tmpa_int}
    \seq_gset_eq:NN \g_patrik_display_seq \l_tmpa_seq
    \seq_map_inline:Nn \g_patrik_display_seq {%
        \prop_item:Nn \g_patrik_problem_prop {defproblem##1}

  \seq_map_inline:Nn \g_patrik_display_seq {%
    \prop_if_in:NnT \g_patrik_hint_prop {hintproblem##1} {
        \prop_item:Nn \g_patrik_hint_prop {hintproblem##1}

\seq_new:N \g_patrik_display_seq% Stores the number of the displayed problems


  Proove $E=mc^{2}$
}[Use your brain]

  Proove that in any rectangular triangle with hypotenuse $c$ and cathetes $a$ and $b$ the theorem of Pythagoras holds: \begin{align}c^{2} &= a^{2} + b^{2}\end{align}
}[Make a sketch]



% Or select some of the problems:




enter image description here

You must log in to answer this question.

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