4

I'm using the scrartcl class provided by KOMA to write all my reports. I'd like the title, author, and date to be flush left (instead of centered).

Following a hint I found once on a german-speaking forum, I tried the following:

\documentclass[english]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{0}

\addtokomafont{title}{\raggedright}
\addtokomafont{author}{\raggedright}
\addtokomafont{date}{\raggedright}

\begin{document}

\title{My report}

\author{Joe User}
\maketitle

\section{Introduction}

Some intro
\end{document}

This yields almost the desired result, except that a small space comes in front of the author:

enter image description here

Am I doing anything wrong here? What would be the correct way to do this?

2 Answers 2

4

KOMA-Script like the standard classes use tabular environments to set the authors. The code is:

\begin{tabular}[t]{c}%
  \@author
\end{tabular}

As you can see, the initial and the final column separator is not removed in this declaration. So if you misuse the font settings to try to force the author left aligned, only the tabular will be left aligned but the tabular still starts with a column separation space of width \tabcolsep.

You can use package xpatch to change the tabular declaration in \@maketitle. And if you already do so, you can also replace the center environment by a flushleft environment and avoid the ugly misusage of the font settings:

\documentclass[english]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\setcounter{secnumdepth}{0}

\usepackage{xpatch}
\makeatletter
\xpatchcmd{\@maketitle}{\begin{center}}{\begin{flushleft}}{}{}
\xpatchcmd{\@maketitle}{\end{center}}{\end{flushleft}}{}{}
\xpatchcmd{\@maketitle}{\begin{tabular}[t]{c}}{\begin{tabular}[t]{@{}l@{}}}{}{}
\makeatother

\begin{document}

\title{My report}

\author{Joe User}
\maketitle

\section{Introduction}

Some intro
\end{document}

This patches can be used for the standard class article too.

If you have more than one author separated by \and, you may also change the definition of \and inside the definition of \maketitle, e.g.

\xpatchcmd{\maketitle}{%
  \def\and{%
    \end{tabular}%
    \hskip 1em \@plus.17fil%
    \begin{tabular}[t]{c}%
  }%
}{%
  \def\and{%
    \end{tabular}\\
    \begin{tabular}[t]{@{}l@{}}%
  }%
}{}{}

to not longer have the authors side by side but one below the other. This last patch does not work for the standard classes. For the standard classes you can simply redefine \and:

\renewcommand*\and{%
  \end{tabular}\\
  \begin{tabular}[t]{@{}l@{}}%
}%

without \xpatchcmd.

If you want a clean solution: Do not use the default \maketitle if you don't like it. Define you own title if you need more freedom than the class provides.

1
  • 2
    Using xpatch is way much cleaner than fiddling with scrartcl.cls (-; ! Thanks! (... and +1 for last sentence!)
    – ebosi
    Apr 12, 2017 at 14:23
1

In scrartcl.cls, you can observe the following in the definition of \maletitle:

[...]
{%
  \usekomafont{author}{%
    \lineskip .5em%
    \begin{tabular}[t]{c}
      \@author
    \end{tabular}\par
  }%
}%
[...]

As highlighted by Schweinebacke in the comments, the artifact is actually cause by the left margin of the tabular. You could thus redefine it as following:

{%
  \usekomafont{author}{%
    \lineskip .5em%
    \begin{tabular}[t]{@{}c@{}}%<=== removed left and right columnsep
      \@author
    \end{tabular}\par
  }%
}%

enter image description here

However, be careful!! Do not modify the source of scrartcl.cls directly. Make a copy of it, make some changes and change the name and the preamble of the new file (basically, create a "modifiedscrartcl" class).

5
  • 1
    Is that your way of saying there's a bug in scrartcl? ;-)
    – lindelof
    Apr 12, 2017 at 13:47
  • @lindelof I am way not sure enough to suggest this! Moreover, it should not be a "bug" since it was not intended to left-alignment...
    – ebosi
    Apr 12, 2017 at 13:48
  • 3
    \Large is macro. White spaces after macros are ignored. I would say, the problem is the tabular with the column separation before the first column. Apr 12, 2017 at 14:02
  • 1
    The original answer about the missing EoL-% is misleading. I would remove that part.
    – Johannes_B
    Apr 12, 2017 at 16:24
  • @Johannes_B you are right. done.
    – ebosi
    Apr 12, 2017 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .