调整文章标题

调整文章标题

我在调整标题时遇到以下问题:

\documentclass[11pt, a4paper, german]{article}
\usepackage{color}
\usepackage{amsmath, amsfonts, amsthm,}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{mathrsfs}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{pgfplots}
\usepackage{graphicx} 
\usepackage{array}
\usepackage{scrpage2}
\ohead{\headmark}
\pagestyle{scrheadings}
\automark{section}

\usepackage{geometry}
\geometry{a4paper,left=40mm,right=30mm, top=2cm, bottom=2cm}

\begin{document}
\section{A}
\newpage

\section{BBBTest}
\end{document}

我尝试了fancyhdrplain并且标题都准备好了,但它对我来说不起作用。例如,它将标题放在彼此之上。这里我遇到的问题是它将标题放在左侧和右侧两次。

我想要的是:页面中间底部的页码和左上角部分或小节的标题,标题下方有一条线。

我希望有一个人可以帮助我。

答案1

好吧,对于类,article我更喜欢使用包fancyhdr。包scrpage2已过时,请改用包scrlayer-scrpage!因为你用德语写作,你考虑过改用类吗scrartcl?并且scrlayer-scrpage设计为与任何 KOMA-Script 类配合最佳,例如scrartcl...

article尽管如此,这里是类和的解决方案scrlayer-scrpage

您需要添加选项headsepline以获取标题下的所需行,并且需要添加命令\clearscrheadfoot来摆脱包scrlayer-scrpage通常进行的所有预定义......

请参阅以下 MWE(带有blindtext向文档中添加一些虚拟文本的包):

\documentclass[%
  11pt, 
  a4paper,
  ngerman
]{article}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{geometry}
\geometry{a4paper,left=40mm,right=30mm, top=2cm, bottom=2cm}

\usepackage{blindtext}

\usepackage[%
  headsepline, % <======================================================
]{scrlayer-scrpage} % <=================================================
\pagestyle{scrheadings}
\clearscrheadfoot % <========================== clear all pre-definitions
\ohead{\headmark}
\cfoot{\pagemark}
\automark{section}


\begin{document}
\tableofcontents
\section{A}
\blindtext
\newpage

\section{BBBTest}
\blindtext
\end{document}

还请注意,我删除了此问题中所有不需要的包!现在您将获得以下结果:

结果页面

您是否注意到编译我的 MWE 时应该收到的警告?它是:

Package scrlayer-scrpage Warning: \headheight to low.
(scrlayer-scrpage)                At least 13.59999pt needed,
(scrlayer-scrpage)                but only 12.0pt found.
(scrlayer-scrpage)                I'll enlarge \headheight, for further
(scrlayer-scrpage)                processing, but you should do this yourself,
(scrlayer-scrpage)                e.g., setting geometry's option
(scrlayer-scrpage)                `head=13.59999pt'.
(scrlayer-scrpage)                I'll also decrease \topmargin on input line 30.

head=13.6pt因此您应该添加以下选项geometry

\geometry{%
  a4paper,left=40mm,right=30mm, top=2cm, bottom=2cm, 
  head=13.6pt % <=======================================================
}

使用新的 MWE,您可以进行编译而不会出现错误消息或警告:

\documentclass[%
  11pt, 
  a4paper,
  ngerman
]{article}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{geometry}
\geometry{%
  a4paper,left=40mm,right=30mm, top=2cm, bottom=2cm, 
  head=13.6pt % <=======================================================
}

\usepackage{blindtext}

\usepackage[%
  headsepline, % <======================================================
]{scrlayer-scrpage} % <=================================================
\pagestyle{scrheadings}
\clearscrheadfoot % <========================== clear all pre-definitions
\ohead{\headmark}
\cfoot{\pagemark}
\automark{section}


\begin{document}
\tableofcontents
\section{A}
\blindtext
\newpage

\section{BBBTest}
\blindtext
\end{document}

结果如下:

在此处输入图片描述

相关内容