我目前正在撰写我的学士论文。我使用该软件包srclayer-scrpage
制作标题。由于我不需要打印我的论文,所以它是单面文档。我希望当前章节或子章节名称位于右侧。我可以使用 或 ,但\automark{subsection}
如果\automark{section}
是\automark{subsection}
,则没有子章节的章节将标记为最新子章节,如果没有\automark{section}
子章节,则将标记 。您有什么想法可以在标题中合并章节和子章节吗?
这是我的代码的一个小示例:
\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}
答案1
也许你想使用
\automark{section}
\automark*{subsection}
例子:
\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}