3

The following MWE shows that the second section is black instead of red. Even if this happens only if there is no text between these two sections: Is this a bug?

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{scrlayer-scrpage}

\addtokomafont{section}{\color{red}}
\addtokomafont{pageheadfoot}{\color{blue}}

\begin{document}
...
\\[0.84\textheight]
\section{Test}
\section{Test}
\end{document}

enter image description here

  • Just found out that the page break between sections will never happen if I use \textcolor instead of \color. Looks like \textcolor is more stable: tex.stackexchange.com/questions/86039/… – Stefan Braun Jun 11 '16 at 13:55
  • \RedeclareSectionCommand[font=\large\bfseries\sffamily\color{red}]{section} – Johannes_B Jun 11 '16 at 14:00
  • 1
    I am saying that the above abviously works but has some downsides. You should report the behaviour to komascript.de – Johannes_B Jun 11 '16 at 14:05
  • 1
    @StefanBraun \color{red} is allowed in \addtokomafont, \setkomafont and as value for the font option in \RedeclareSectionCommand. AFAIK the problem will be solved in the next KOMA-Script version (3.21). – esdd Jun 12 '16 at 18:59
  • 1
    @Johannes_B In your suggestion \large is used. Change it to \Large (default for sections in scrartcl) and you get the page break and the black color. – esdd Jun 12 '16 at 20:05
2

The bug is fixed in KOMA-Script Version 3.21 which is the current version on CTAN, in TeX Live 2016 and in MiKTeX.

\documentclass{scrartcl}[2016/06/14]
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{scrlayer-scrpage}

\addtokomafont{section}{\color{red}}
\addtokomafont{pageheadfoot}{\color{blue}}

\begin{document}
...
\\[0.84\textheight]
\section{Test}
\section{Test}
\KOMAScriptVersion
\end{document}

results in

enter image description here

3

You should use \leavevmode before the color command. This will avoid that a page break can occur between the color and the title of the section.

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{scrlayer-scrpage}

\addtokomafont{section}{\leavevmode\color{red}}
\addtokomafont{pageheadfoot}{\color{blue}}

\begin{document}
...
\\[0.84\textheight]
\section{Test}
\section{Test}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.