1

I have

\documentclass[11pt]{article}
\usepackage{amsthm}
\usepackage{etoolbox}
\newtoggle{sol}
\toggletrue{sol}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
    Text
    \iftoggle{sol}{Text}
\end{theorem}
\end{document}

and I am getting and error sayin that \begin{theorem} was ended by \end{document}.

What might I be doing wrong?

3
  • Welcome to TeX.SX! Can you please expand the code snippets that you have posted to a full minimal working example. It is much easier to help you you if we can start with some code that illustrates your problem. A MWE should start with a \documentclass command, include any necessary packages and be as small as possible to demonstrate your problem. It's really hard to trouble shoot an error if you are not given enough code to reproduce it.
    – user30471
    Dec 5, 2017 at 13:43
  • @Andrew: Done ...
    – Thomas
    Dec 5, 2017 at 13:46
  • 1
    If should be \iftoggle{sol}{true code}{false code}. As you haven't given the false code the \end{theorem} is being eaten up and used as this instead, causing your error.
    – user30471
    Dec 5, 2017 at 13:48

1 Answer 1

3

\iftoggle expects three arguments. One for the toggle, one for the true-branch and one for false. You should use it like this:

\documentclass[11pt]{article}
\usepackage{amsthm}
\usepackage{etoolbox}
\newtoggle{sol}
\toggletrue{sol}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
    Text
    \iftoggle{sol}{Text}{}
\end{theorem}
\end{document}

Without the additional {} \end gets eaten by \iftoggle.

0

You must log in to answer this question.

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