I use the "variables" in my header and would like to shorten the code by combining \ifdefined\@@author
and \ifdefined\@group
. Searching the repository for "ifdefined multiple arguments" etc. didn't give a useful result. I experimented with ||
, as from different programming languages, but you can imagine... :)
Is there no easier way to do that?
\rhead{\small\color{darkgray2}%
\ifdefined\@@author%
\@@author%
\ifdefined\@group%
, %
\fi%
\fi%
\ifdefined\@group%
\@group%
\fi%
\ifdefined\@@date%
\linebreak\@@date%
\fi%
}
Thanks.
Edit (MWE):
\LoadClass{article}
\newcommand\group[1]{\def\group{#1}}
\author{Me}
\group{Group}
\title{Work Hygiene and Safety}
\date{18th~September~2018}
\RequirePackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}%
\makeatletter
\rhead{
\ifdefined\@author%
\@author%
\ifdefined\group%
, %
\fi%
\fi%
\ifdefined\group%
\group%
\fi%
\ifdefined\@date%
\linebreak\@date%
\fi%
}
\makeatother
\begin{document}
Hello
\end{document}
\if
combinations. – David Carlisle Sep 2 '18 at 8:55%
at the ends of exactly the wrong lines, you need one after\rhead{
but the ones after command names like\group%
do nothing as white space is ignored after a command name. – David Carlisle Sep 2 '18 at 8:59\newcommand\group[1]{\def\group{#1}}
to be\newcommand\group[1]{\def\@group{#1}}
– David Carlisle Sep 2 '18 at 9:02