0

I've a documentclass myclass that's based on KOMA-script's scrartcl class.

MWE: myclass.cls

\NeedsTeXFormat{LaTeX2e}

% The document class name \ProvidesClass{myclass}

% https://tex.stackexchange.com/a/121829 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrartcl}} \ProcessOptions\relax \PassOptionsToPackage{headlines=3}{typearea}

% The document class to base this class on \LoadClass{scrartcl}

\RequirePackage[headsepline]{scrlayer-scrpage}

% The page headers \lohead{\csname @author\endcsname\Foo\Bar}

How do I conditionally insert \csname @author\endcsname\\ in the beginning of lohead iff the argument to the command* \author{} is non-empty? The issue is that currently a newline is always inserted into the header.


* Unsure of the terminology here.

Bernard
  • 271,350
a12l
  • 27

1 Answers1

1

You can do it like Koma-Script does, have a look at the definition of \maketitle in scrartcl.cls for examples.

\makeatletter
  \lohead{\ifx\@author\@empty\else\@author\\\fi Foo\\Bar}
\makeatother

If you are sure that \@author will not be changed after \begin{document}, you can also do the check just once.

\makeatletter
  \AtBeginDocument{%
    \ifx\@author\empty
      \lohead{Foo\\Bar}%
    \else
      \lohead{\@author\\Foo\\Bar}%
    \fi
  }
\makeatother
schtandard
  • 14,892