1

I am currently working on my bachelor thesis. I use the package srclayer-scrpage for headlines. As I don't need to print my thesis, it is a one-sided document. I want the current section or subsection name on the right side. I can use either \automark{subsection} or \automark{section} but in case of \automark{subsection}, a section with no subsections will be marked with the latest subsection and in case of \automark{section} no subsection will be marked. Have you any ideas to combine section and subsections in the headline?

Here is a small example of my code:

\documentclass[11pt, a4paper, german]{scrartcl}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage[headsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\clearscrheadfoot
\ohead{\headmark}
\cfoot{\pagemark}
\automark{subsection}

 \begin{document}
    \section{first section}
    This is a section with subsections, so using $\backslash$automark\{subsection\} will not cause any problems.
    \subsection{first subsection}first subsection
    \newpage \subsection{second subsection} second subsection
    \newpage \section{second section} This is a section with no subsections, so in the headline will appear \glqq second subsection\grqq \ instead of \glqq second section\grqq. How can I fix this? 
 \end{document}
0

Maybe you want to use

\automark{section}
\automark*{subsection}

Example:

\documentclass[
  %11pt, a4paper,% default
  ngerman
]{scrartcl}
\usepackage{babel}
%\usepackage[utf8]{inputenc}% needed for older TeX distributions
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage[headsepline]{scrlayer-scrpage}% sets pagestyle schrheadings automatically
\automark{section}
\automark*{subsection}
\clearpairofpagestyles% replaces outdated macro \clearscrheadfoot
\ohead{\headmark}
\cfoot*{\pagemark}% pagenumber should be on plain pages, too

 \begin{document}
    \section{first section}
    This is a section with subsections, so using $\backslash$automark\{subsection\} will not cause any problems.
    \subsection{first subsection}first subsection
    \newpage \subsection{second subsection} second subsection
    \newpage \section{second section} This is a section with no subsections, so in the headline will appear \glqq second subsection\grqq \ instead of \glqq second section\grqq. How can I fix this? 
 \end{document}
1
  • Yes, that's exactly what I wanted, thanks!
    – Guest
    Aug 6 '20 at 13:38

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.