I wish to include a question/solution bank at the end of the chapter. I want to be able to control its printing via a single comment/uncomment operation. The MWE is an article but my intention is to produce a collection of books with 30+ chapters each. All the books share a common preamble file.

The questions are to be printed as a two column multicol. I am using a conditional compilation as outlined in [ How to easily write conditional pages? ] I dont claim to understand it, but it has worked for me so far. The only problem I face is when nesting it inside a \newenvironment.

In particular, there are two problems (indicated in the MWE with PROB-1 and PROB-2 tags) I face here -

  1. Nesting multicol in a new environment qbank throws up compilation error. But nesting multicol in a \newenvironment[quescol] and nesting quescol in qbank seems to work. Which puzzles me. In any case I can possibly live with it but would still like to know the real reason.
  2. The conditional compilation scheme does not work as desired. The MWE compiles correctly but I cannot comment out \SelectPartsForCompilation{queb} as desired. I cannot put \DeclareCompilationNameOfBlock[queb] outside \begin{qbank} block as qbank is in literally 100s of chapters (each in a separate file).

Actually nesting this conditional compilation scheme in any \newenvironment does produce a mess. PS: In my real documents there are several more compile tags besides queb.


    \pgfkeys@temptoks{#2}\expandafter\xdef\csname pgfk@#1\endcsname{\the\pgfkeys@temptoks}

\pgfkeys{/DeclareCompilationNameOfLine/.is family,/DeclareCompilationNameOfLine,

    \foreach \key in {#1}{\pgfkeys{/DeclareCompilationNameOfLine,set/\key} }
    \foreach \key in {#1,all} {
            \ifnum\temp=1\global\PrintCommenttrue\fi% print if key=1

\NewEnviron{DeclareCompilationNameOfBlock}[1][]{\MakeSelection{#1}\ifPrintComment\BODY\fi }

\newenvironment{quescol}{ % PORB-1 :: I am forced to use this clunky envirnoment
    } {

            \textbf{\textit{\LARGE Question Bank}}
        \quescol % PROB-1 :: if I directly use \begin{multicols}{2}, i get compliation error
    } {

% PROB-2 :: If I comment out the follwing line, it throws up a compilation error
\SelectPartsForCompilation{queb} % comment this line for not including the question bank in PDF

    \section{first} Text of first
    \section{second} Text of second
    \section{third} Text of third

Your Answer

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

Browse other questions tagged or ask your own question.