2

I want to have a section at the end of each chapter with the solutions of only odd-numbered questions.

2
  • It seems to me the O.P. raised a quite sensible question.
    – Bernard
    Dec 13, 2015 at 14:49
  • Done. I had missed that answer... Feb 10, 2016 at 5:15

1 Answer 1

3

If you want \printsolution[section] to only print the solutions of odd numbered questions you can add

\usepackage{exsheets}[2016/01/26]% make sure you have v0.21 available

\ExplSyntaxOn
\cs_set_protected:Npn \__exsheets_print_solutions_section:nnn #1#2#3
  {
    \exsheets_print_solutions_if:nnn
      {
        \int_if_odd_p:n  { \l_exsheets_counter_qu_int } &&
        \int_compare_p:n { \l__exsheets_counter_sec_int = #3 }
      }
      {#1}
      {#2}
  }
\ExplSyntaxOff

to you document. Since this redefines an internal function this is not entirely safe, though.

\documentclass[twocolumn]{article}
\usepackage{exsheets}[2016/01/26]

\ExplSyntaxOn
\cs_set_protected:Npn \__exsheets_print_solutions_section:nnn #1#2#3
  {
    \exsheets_print_solutions_if:nnn
      {
        \int_if_odd_p:n  { \l_exsheets_counter_qu_int } &&
        \int_compare_p:n { \l__exsheets_counter_sec_int = #3 }
      }
      {#1}
      {#2}
  }
\ExplSyntaxOff

\begin{document}

\section{One}
\subsection{Exercises}
\begin{question}
  qu one
\end{question}
\begin{solution}
  sol one
\end{solution}

\begin{question}
  qu two
\end{question}
\begin{solution}
  sol two
\end{solution}

\begin{question}
  qu three
\end{question}
\begin{solution}
  sol three
\end{solution}

\begin{question}
  qu four
\end{question}
\begin{solution}
  sol four
\end{solution}

\begin{question}
  qu five
\end{question}
\begin{solution}
  sol five
\end{solution}

\subsection{Solutions}
\printsolutions[section]

\newpage

\section{Two}
\subsection{Exercises}
\begin{question}
  qu one
\end{question}
\begin{solution}
  sol one
\end{solution}

\begin{question}
  qu two
\end{question}
\begin{solution}
  sol two
\end{solution}

\begin{question}
  qu three
\end{question}
\begin{solution}
  sol three
\end{solution}

\begin{question}
  qu four
\end{question}
\begin{solution}
  sol four
\end{solution}

\begin{question}
  qu five
\end{question}
\begin{solution}
  sol five
\end{solution}

\subsection{Solutions}
\printsolutions[section]

\end{document}

enter image description here

You must log in to answer this question.

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