0

To center a cropped page in combination with \newgeometry one can add

\makeatletter\CROP@center\makeatother

after each change of geometry (https://tex.stackexchange.com/a/118824/61658).

Using the \etoolbox package, one can define a toggle to switch the cropping on and off via

\usepackage{etoolbox}
\newtoggle{crop}
\settoggle{crop}{true}

in combination with

\iftoggle{crop}{...}{}.

When I do this (see source code below), I get the following error:

Undefined control sequence. <argument> \makeatletter \CROP @center \makeatother

Removing the toggle fixes the error.

Here is the MWE:

\documentclass[
    paper=a4,
    DIV=10,
    twoside=true,
    titlepage=on
]{scrbook}

\usepackage[
    pass,
]{geometry}

\usepackage{etoolbox}
    \newtoggle{crop}
    \settoggle{crop}{true}

\iftoggle{crop}{
    \usepackage[
        width=21.6truecm, height=30.3truecm,
        cross, axes,
        pdftex,
        center,
        noinfo
    ]{crop}
}

\usepackage{blindtext}


\begin{document}

% Standard page (right)
\Blindtext[2]

% Centered page (left)
\newgeometry{centering}
%%% TODO Delete following line to fix error.
\iftoggle{crop}{
    \makeatletter \CROP@center \makeatother
%%% TODO Delete following line to fix error.
}
\Blindtext[2]
\restoregeometry
%%% TODO Delete following line to fix error.
\iftoggle{crop}{
    \makeatletter \CROP@center \makeatother
%%% TODO Delete following line to fix error.
}

% Standard page (right)
\Blindtext[2]

% Standard page (left)
\newpage
\Blindtext[2]

% Standard page (right)
\newpage
\Blindtext[2]

\end{document}
2
  • \iftoggle has three arguments.

    \iftogle{<toggle>}{<true>}{<false>}
    

    You're missing the <false> case each time you use it (also in the preamble)

  • put \makeatletter and \makeatother outside of the conditional. Once it has read (and tokenized) its arguments the @ of \CROP@center can't be changed any more. That's why the change has to happen before the argument is read.

    \makeatletter
      \iftoggle{crop}
        {\CROP@center}
        {}
    \makeatother
    
  • Thank you for the solution (and also for correcting the careless mistake with the missing argument of \iftoggle)! – jpmath Mar 16 '17 at 10:41

Your Answer

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

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