1

I am trying to write a simple command that toggles margin sides. It uses \normalmarginpar or \reversemarginpar, but the user doesn't have to keep track of whether it was already reversed or normal. I tried this.

\documentclass{amsart}

\newcommand{\switchmargin}{
\if@reversemargin
\normalmarginpar
\else
\reversemarginpar
\fi
}


\begin{document}

Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\marginpar{Marginal note}

\switchmargin
Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\marginpar{Marginal note}

\switchmargin
Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\marginpar{Marginal note}

\end{document}  

However, my marginal notes switch to revers but never toggle back: The first note is on the right (normal) side, and all subsequent notes are on the left (reversed) side.

If I understand correctly, @reversemargin is the boolean that keeps track of whether the margin is reversed or not, so I'm not seeing why this doesn't work.

  • You are missing \makeatletter before the definition. – Ulrike Fischer May 15 at 18:08
  • Ah, I see that this question was not so much about marginpars but about a way to display my ignorance. Indeed, if I surround my definition with \makeatletter ... \makeatother, everything suddenly works. Advice from more experienced stackexchange hands? Do I delete the question? Edit it (even though there isn't really a question left)? In any case, thanks @UlrikeFischer, because it's working now. – Nathan Reading May 15 at 18:31

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.