我使用的模板本质上是 smfbook 模板(提供这里)我很喜欢它,但我想改变一些细节:
第一个是页眉。默认情况下,在偶数页中我们得到“第十章。章节标题”。我想删除第一部分“第十章”。此外,在奇数页中,它写着 X.2 第 2 节的名称。我想得到“S(节符号\S
)2。第 2 节的名称”。页眉部分在这里:
% Headers
\def\ps@empty{\let\@mkboth\@gobbletwo
\let\@oddhead\@empty \let\@evenhead\@empty
\let\@oddfoot\@empty \let\@evenfoot\@empty
\global\topskip\normaltopskip}
\def\ps@plain{\ps@empty
\def\@oddfoot{\normalfont\scriptsize \hfil\thepage\hfil}%
\let\@evenfoot\@oddfoot}
\def\ps@headings{\ps@empty
\def\@oddfoot{}%
\def\@evenfoot{}%
\def\@evenhead{\normalfont\scriptsize
\rlap{\bfseries\thepage}\hfil \leftmark{}{}\hfil}%
\def\@oddhead{\normalfont\scriptsize
\hfil \rightmark{}{}\hfil \llap{\bfseries\thepage}}%
\let\@mkboth\markboth
\def\partmark {\@secmark\markboth\partrunhead\partname}%
\def\chaptermark {\@secmark\markboth\chapterrunhead\chaptername}%
\def\sectionmark {\@secmark\markright\sectionrunhead\sectionname}%
\def\indexmark {\@secmark\markboth\indexrunhead\indexname}%
}
\let\ps@copyright\ps@empty
\def\ps@myheadings{\ps@headings \let\@mkboth\@gobbletwo}
\def\leftmark{\expandafter\@firstoftwo\topmark{}{}}
\def\rightmark{\expandafter\@secondoftwo\botmark{}{}}
\long\def\@nilgobble#1\@nil{}
\def\@secmark#1#2#3#4{%
\begingroup \let\protect\@unexpandable@protect
\edef\@tempa{\endgroup \toks@{\@nx#2{#3}{\@secnumber}}}%
\@tempa
\toks@\@xp{\the\toks@{#4}}%
\afterassignment\@nilgobble\@temptokena\@themark{}\@nil
\edef\@tempa{\@nx\@mkboth%
{\ifx\markright#1\the\@temptokena\else\the\toks@\fi}%
{\the\toks@}}%
\@tempa}
\let\@secnumber\@empty
\def\markboth#1#2{%
\begingroup
\@temptokena{{#1}{#2}}\xdef\@themark{\the\@temptokena}%
\mark{\the\@temptokena}%
\endgroup
\if@nobreak\ifvmode\nobreak\fi\fi}
\let\partmark\@gobble
\let\tocmark\@gobble
\let\sectionmark\@gobble
\let\subsectionmark\@gobble
\let\subsubsectionmark\@gobble
\let\paragraphmark\@gobble
但我不知道如何更改它。请注意,由于我有代码,因此我的想法是避免使用一些额外的包,例如fancyhdr
。
以下是 MWE:
\documentclass[12pt,english]{sfmbook}
\usepackage{lipsum}
\author{Me}
\title{My book}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\chapter{One}
\section{A}
\begin{remark}
This is a remark.
\end{remark}
And this is a theorem
\begin{theorem}
Hello :)
\end{theorem}
\lipsum[1-5]
\section{B}
\lipsum[1-5]
\chapter{Two}
\section{A}
\lipsum[1-5]
\section{B}
\lipsum[1-5]
\lipsum[1-5]
\section{C}
\lipsum[1-5]
\chapter{Three}
\section{A}
\lipsum[1-5]
\section{B}
\lipsum[1-5]
\chapter{Four}
\section{A}
\lipsum[1-5]
\section{B}
\lipsum[1-5]
\chapter{Five}
\section{A}
\lipsum[1-5]
\section{B}
\lipsum[1-5]
\end{document}
答案1
这是两个不同的问题。我只回答第一个问题。也许你可以针对第二个问题提出一个新问题。
您必须重新定义\chapterrunhead
:
\makeatletter
\def\chapterrunhead#1#2#3{%
\@ifnotempty{#3}{\MakeUppercase{#3}}%
}
\makeatother
和\sectionmarkhead
\makeatletter
\def\sectionmark{\@secmark\markright\sectionrunhead\S}
\makeatother
有可能\sectionrunhead
\makeatletter
\def\sectionrunhead#1#2#3{%
\@ifnotempty{#2}
{\MakeUppercase{#1 \arabic{section}}\@ifnotempty{#3}{.\ }}%
\@ifnotempty{#3}{\MakeUppercase{#3}}%
}
\makeatother
代码:
\documentclass[12pt,english]{smfbook}
\makeatletter
\def\chapterrunhead#1#2#3{%
\@ifnotempty{#3}{\MakeUppercase{#3}}%
}
\def\sectionmark{\@secmark\markright\sectionrunhead\S}
\def\sectionrunhead#1#2#3{%
\@ifnotempty{#2}
{\MakeUppercase{#1 \arabic{section}}\@ifnotempty{#3}{.\ }}%
\@ifnotempty{#3}{\MakeUppercase{#3}}%
}
\makeatother
\usepackage{lipsum}
\author{Me}
\title{My book}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\chapter{One}
\section{A}
\lipsum[1-5]
\section{B}
\lipsum[1-5]
\chapter{Two}
\section{A}
\lipsum[1-5]
\section{B}
\lipsum[1-5]
\lipsum[1-5]
\section{C}
\lipsum[1-5]
\end{document}