Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to detect whether the exercise package's option noanswer is on, with the intention of not displaying parts in either mode.

Here is my mwe:


\documentclass{minimal}
\usepackage[noaswer]{exercise}

\newif\ifpaper
\newif\ifmemo
\paperfalse
\memofalse

\makeatletter%
\@ifpackagewith{excercise}{noanswer}{%
\papertrue%
}{%
\memotrue%
}%
\makeatother%

\begin{document}
\ifpaper
paper
\fi

\ifmemo
memo
\fi

\end{document}

With this I always get memo, whether noanswer is provided or not.


  1. Is there something I'm missing?
  2. Or there another approach to ensure the correct detection?
share|improve this question

closed as too localized by Matthew Leingang, Kurt, Claudio Fiandrino, Torbjørn T., Xavier May 15 '13 at 14:12

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Does changing \@ifpackagewith{excercise}{noanswer} to \@ifpackagewith{exercise}{noanswer} help? –  Matthew Leingang May 15 '13 at 12:50
    
Yes it does! I don't know why I did not check for something as simple as that! –  Louis May 15 '13 at 12:53
1  
Glad it helps. I'm voting to close the question as Too Localized since it's not likely to come up again. –  Matthew Leingang May 15 '13 at 12:56
add comment

1 Answer

up vote 2 down vote accepted

Package exercise knows several options that disable the answers: noanswer, exerciseonly; and outputnothing also disables exercise output. Internally the packages uses switches: \if@AnswerOutput for answers and \if@ExerciseOutput for exercises. Thus the first switch provides an alternative to checking the option using \@ifpackagewith:

\documentclass{minimal}
\usepackage[noanswer]{exercise}

\newif\ifpaper
\newif\ifmemo
\paperfalse
\memofalse

\makeatletter
\if@AnswerOutput
  \memotrue
\else
  \papertrue
\fi
\makeatother

\begin{document}
\ifpaper
paper
\fi

\ifmemo
memo
\fi

\end{document}
share|improve this answer
    
Thanks for your answer, I will definitely use it. The original problem was as @Matthew Leingang pointed out a simple typo! –  Louis May 15 '13 at 14:16
add comment

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