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}
0

1 Answer 1

1
  • \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
    
1
  • Thank you for the solution (and also for correcting the careless mistake with the missing argument of \iftoggle)!
    – user61658
    Commented Mar 16, 2017 at 10:41

You must log in to answer this question.