Using conditionals to ignore command does not work
Usual problem with skipping over conditionals. If the outer condition is false then Tex will be skipping over this
\patchcmd{\slideentry}{\ifnum#2>0}{\ifnum2>0}{
so it will not expand \patchcmd
in any way but it will see two \ifnum
and add them to its internal \if
matching and so will expect to see two \fi
closing the inner ifs.
You could give it two \fi
with \@gobble{\fi\fi}
or similar but less obscure and more maintainable would be to put the patching into an external file that you input so it isn't seen when skipping.
When skipping tokens in an unused branch of a conditional, TeX still keeps track of conditionals, so when \iftargetBeamer
is false, the two \ifnum
are paired with the only two \fi
tokens you provide.
Just remove \ifnum
, because it's not required for the patch.
\newif\iftargetReport
\newif\iftargetBeamer
\targetReporttrue
%\targetBeamertrue
\iftargetReport
\documentclass[a4paper, 12pt, ngerman]{scrreprt}
\else
\iftargetBeamer
\documentclass[ignorenonframetext, ngerman]{beamer}
\else
\typeout{no valid class defined, enter Ctrl-D (Linux) or Ctrl-Z (Windows)}
\expandafter\expandafter\expandafter\endinput
\fi
\fi
\iftargetBeamer
\makeatletter
\usepackage{etoolbox}
% replace the subsection number test with a test that always returns true
\patchcmd{\slideentry}
{#2>0}
{2>0}
{}{\@error{unable to patch}}
% use frame numbers instead of subsection slide numbers so that frames
% broken over slides get separate circles
\patchcmd{\slideentry}
{\c@subsectionslide}
{\c@framenumber}
{}{\@error{unable to patch}}
\patchcmd{\beamer@writeslidentry}
{\c@subsectionslide}
{\c@framenumber}
{}{\@error{unable to patch}}
\makeatother
\else
\usepackage{beamerarticle}
\fi
\begin{document}
\begin{frame}
Some text.
\end{frame}
\end{document}
Alternatively, use regexpatch
, so you can “hide” the conditional.
\newif\iftargetReport
\newif\iftargetBeamer
\targetReporttrue
%\targetBeamertrue
\iftargetReport
\documentclass[a4paper, 12pt, ngerman]{scrreprt}
\else
\iftargetBeamer
\documentclass[ignorenonframetext, ngerman]{beamer}
\else
\typeout{no valid class defined, enter Ctrl-D (Linux) or Ctrl-Z (Windows)}
\expandafter\expandafter\expandafter\endinput
\fi
\fi
\iftargetBeamer
\makeatletter
\usepackage{regexpatch}
% replace the subsection number test with a test that always returns true
\regexpatchcmd{\slideentry}
{\c{ifnum}\cP.2>0}
{\c{iftrue}}
{}{\@error{unable to patch}}
% use frame numbers instead of subsection slide numbers so that frames
% broken over slides get separate circles
\xpatchcmd{\slideentry}
{\c@subsectionslide}
{\c@framenumber}
{}{\@error{unable to patch}}
\xpatchcmd{\beamer@writeslidentry}
{\c@subsectionslide}
{\c@framenumber}
{}{\@error{unable to patch}}
\makeatother
\else
\usepackage{beamerarticle}
\fi
\begin{document}
\begin{frame}
Some text.
\end{frame}
\end{document}