标头问题

标头问题

目前,我正在尝试改进论文的布局。我想添加一个页眉,其中小节标题位于右侧。但它应该只出现在没有开始新章节的页面上。因此,例如,如果简介从第 2 页开始,则小节标题应首先出现在第 3 页,依此类推。对于第 2 页,我选择\pagestyle{plain},对于文档的其余部分则选择\pagestyle{fancy}。现在文档要么在每一页上打印小节标题,要么根本不打印。我该如何解决这个问题? (代码更新)

\documentclass[a4paper,12pt,draft]{report}

\usepackage{ucs}
\usepackage[utf8x]{inputenc} % Eingabekodierung: UTF-8
\usepackage[T1]{fontenc} % ordentliche Trennung
\usepackage[french,USenglish,UKenglish,ngerman]{babel}
\usepackage{blindtext}
\usepackage{lmodern} % ordentliche Schriften
\usepackage[babel,style=swiss,maxlevel=3,threshold=3]{csquotes}
\usepackage{extsizes}

\usepackage{graphicx}
\usepackage{float}
\usepackage[top=2.5cm,bottom=3.5cm,left=2.5cm,right=4cm]{geometry}
\usepackage{hyperref}
\usepackage{lettrine}
\usepackage{indentfirst}
\usepackage{poetrytex}

\usepackage{titlesec}
\titlespacing{\chapter}{0pt}{24pt}{12pt}
\titlespacing{\section}{0pt}{24pt}{12pt}
\titlespacing{\subsection}{0pt}{24pt}{12pt}
\usepackage{setspace}
\usepackage{epigraph}
    \setlength\epigraphwidth{0.75\textwidth}
    \setlength\epigraphrule{0pt}
    \renewcommand{\epigraphsize}{\small}
    \renewcommand{\afterepigraphskip}{12pt}
\usepackage[]{acronym}
\usepackage{hyperhdr}
    \pagestyle{fancy}
    \fancyhf{}
    \renewcommand{\sectionmark}[1]{\markright{#1}}
    \renewcommand{\headrulewidth}{0pt}
    \rhead{\rightmark}
    \lhead{} 
    \rfoot{\thepage}

    \pagestyle{plain}
    \fancyhf{}
    \rfoot{\thepage}

    %   \pagestyle{fancyplain}
    %   \renewcommand{\headrulewidth}{0pt}
    %   \fancyhf{}
    %   \rhead{\rightmark}
    %   \lhead{} 
    %   \rfoot{\thepage}



\pagenumbering{arabic}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
 ...
\end{document}

在我的文档中,我现在使用章节和节。但是,我仍然无法做到在右上角打印节标题,并在每章的第一页上省略它们。另一个问题是,页码打印在每章第一页的中心底部。

另一次代码更新 因此,这就是我的代码现在的样子,还有最后一个问题需要解决:当我编译我的文档时,它只会在标题中设置第一节的标题,而不会设置后续章节的标题,因此总是有相同的章节名称。对我来说,另一个小问题是,它的作用是什么\textheight=250pt,因为当我使用它时,每章的第一页只包含章节的标题和几行文本。然后,当我查看该titlesec部分时,我看到了以下内容:

\titleformat{\chapter}[display]
{\normalfont\Large\bfseries}
{\chaptertitlename\thechapter}{14pt}{\Large}
\titleformat{\subsection}
{\normalfont\large\bfseries}
{\thesection}{14pt}{\large}

[display] 到底是什么意思,为什么我必须写 14pt 并\Large放在曲线括号中?我的目标是以 14pt 大小的正常字体打印章节名称。这是我的整个代码:

\documentclass[a4paper,12pt]{report}

\usepackage{ucs}
\usepackage[utf8x]{inputenc} % Eingabekodierung: UTF-8
\usepackage[T1]{fontenc} % ordentliche Trennung
\usepackage[french,USenglish,UKenglish,ngerman]{babel}
\usepackage{blindtext}
\usepackage{lmodern} % ordentliche Schriften
\usepackage[babel,style=swiss,maxlevel=3,threshold=3]{csquotes}
\usepackage{extsizes}

\usepackage{graphicx}
\usepackage{float}

\usepackage[顶部=2.5cm,底部=3.5cm,左侧=2.5cm,右侧=4cm,headheight=14.5pt]{几何}

%\usepackage{fancyhdr} \usepackage{lettrine} \usepackage{indentfirst} \usepackage{poetrytex}

\usepackage{setspace}
\usepackage{epigraph}
    \setlength\epigraphwidth{0.75\textwidth}
    \setlength\epigraphrule{0pt}
    \renewcommand{\epigraphsize}{\footnotesize}
    \renewcommand{\beforeepigraphskip}{12pt}
    \renewcommand{\afterepigraphskip}{12pt}
\usepackage[]{acronym}
\usepackage{hyperref}
\makeatletter %sorgt dafür, dass die Fußnoten am linken Rand nicht überstehen, sondern mit dem Horizontalstrich gemeinsam schließen.
    \renewcommand{\@makefntext}[1]{
        \parindent 1em%
        \noindent\normalfont\@thefnmark~#1
}
    \makeatother
    % \textheight=\vfill% just for the example

\usepackage[markcase=ignoreupper]{scrlayer-scrpage}
\clearpairofpagestyles
\automark[section]{section}
\ohead{\headmark}
\ofoot*{\pagemark}

\usepackage{titlesec}
    \titlespacing{\chapter}{0pt}{24pt}{12pt} % damit wird der Abstand vor und nach Kapiteln und (Sub-)Sections geregelt
    \titlespacing{\section}{0pt}{24pt}{12pt}
    \titlespacing{\subsection}{0pt}{24pt}{12pt}

    \titleformat{\chapter}[display]
    {\normalfont\Large\bfseries}
    {\chaptertitlename\thechapter}{14pt}{\Large}

    \titleformat{\subsection}
    {\normalfont\large\bfseries}
    {\thesection}{14pt}{\large}




\usepackage{hyperref}
\pagenumbering{arabic}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

好的,这是我的 MWE

\documentclass[a4paper12pt]{article}

\usepackage[utf8x]{inputenc} % Eingabekodierung: UTF-8
\usepackage[T1]{fontenc} % ordentliche Trennung
\usepackage[french,USenglish,UKenglish,ngerman]{babel}
\usepackage{hyperref}
\usepackage{indentfirst}
\usepackage{setspace}
\usepackage{relsize}
\usepackage{acronym}
\usepackage[top=2.5cm,bottom=3.5cm,left=2.5cm,right=4cm,headheight=14.5pt,footnotesep=1cm]{geometry}

\usepackage[markcase=ignoreupper]{scrlayer-scrpage}
    \clearpairofpagestyles
    \automark[section]{section}
    \ohead{\headmark}
    \ofoot*{\pagemark}

\usepackage{titlesec}
    \titlespacing{\chapter}{0pt}{24pt}{12pt} 
    \titlespacing{\section}{0pt}{24pt}{12pt}
    \titlespacing{\subsection}{0pt}{24pt}{12pt}

    \titleformat{\chapter}[display] % why here display and why not with \subsection?
    {\normalfont\Large\bfseries}
    {\chaptertitlename\thechapter}{14pt}{\Large}

    \titleformat{\subsection}
    {\normalfont\large\bfseries}
    {\thesection}{14pt}{\large}


\begin{document}
    \thispagestyle{empty}
    \newgeometry{top=2.5cm,bottom=3.5cm,left=2.5cm,right=4cm}   
    \restoregeometry
    {\large \tableofcontents}
    \clearpage

\newpage    
%   \thispagestyle{fancyplain}
\pagenumbering{roman}
\setcounter{page}{2}
\phantomsection
\subsection*{}
\addcontentsline{toc}{section}{Abbildungsverzeichnis}

\listoffigures 
% \printacronyms{Abkürzungsverzeichnis} mit dem Acro-Package vertraut machen und dann das Abkürzungsverzeichnis schreiben
\phantomsection
\subsection*{Abkürzungsverzeichnis}
\addcontentsline{toc}{section}{Abkürzungsverzeichnis}
\begin{acronym}[Dahlhaus, GS10abc]
    \acro{Hello World}[Hello World]{Hello World}
\end{acronym}
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%The problem lies somewhere here, after the above page with my list of figures, it only prints the List of Figures in the header, but not the subsequent sections' names.
%   \pagestyle{fancy}
%   \thispagestyle{fancyplain}
\phantomsection
\chapter{Einleitung}
\addcontentsline{toc}{chapter}{Einleitung}
\onehalfspacing
\pagenumbering{arabic}
\setcounter{page}{3}
    \section{Hello}
    \section{World}
\end{document}

答案1

的替代包fancyhdrscrlayer-scrpage。它可以做你想做的事。不过我不得不承认,我不知道你为什么要在标题中显示章节标题。

\documentclass[a4paper,12pt,
%draft
]{report}

\usepackage[utf8]{inputenc} % utf8 reicht zu
\usepackage[T1]{fontenc} % ordentliche Trennung
\usepackage[french,USenglish,UKenglish,ngerman]{babel}
\usepackage{blindtext}
\usepackage{lmodern} % ordentliche Schriften
\usepackage[babel,style=swiss,maxlevel=3,threshold=3]{csquotes}
\usepackage{extsizes}

\usepackage{graphicx}
\usepackage{float}
\usepackage[top=2.5cm,bottom=3.5cm,left=2.5cm,right=4cm,
headheight=14.5pt% add a bit for the head
]{geometry}
\usepackage{lettrine}
\usepackage{indentfirst}
\usepackage{poetrytex}


% An alternative to fancyhdr
\usepackage[markcase=ignoreupper]{scrlayer-scrpage}
\clearpairofpagestyles
\automark[section]{section}
\ohead{\headmark}
\ofoot*{\pagemark}

\usepackage{titlesec}
\titlespacing{\chapter}{0pt}{24pt}{12pt}
\titlespacing{\section}{0pt}{24pt}{12pt}
\titlespacing{\subsection}{0pt}{24pt}{12pt}
\usepackage{setspace}
\usepackage{epigraph}
\setlength\epigraphwidth{0.75\textwidth}
\setlength\epigraphrule{0pt}
\renewcommand{\epigraphsize}{\small}
\renewcommand{\afterepigraphskip}{12pt}
\usepackage[]{acronym}


\usepackage{blindtext}%
\usepackage{xcolor}%
\usepackage{hyperref}% at the end


\begin{document}
\listoffigures
\blinddocument
\begin{figure}
\caption{Wombat}
\end{figure}
\end{document}

我做了一些其他更改并用简短的评论标记了它们。

相关内容