我正在尝试整理论文的页面布局。我习惯fancyhdr
在右上角显示页码,在左上角显示章节名称,并在下方设置水平线,并sectsty
为所有章节/子章节等标题设置无衬线字体。
我不喜欢“第十章”字样上方与标题下方的水平线之间有较大的间隙,所以我想减少这个间隙。我已经实现了这个问题的答案:如何减少章节标题前的间距?但我并不满意:正如您从下面的 MWE 中看到的那样,我必须重新定义所有 ToC/LoF/LoT/Bibliography 命令,并且chapter*
似乎也恢复了衬线字体。
简而言之,这似乎非常麻烦。真的没有更优雅的方法吗?如果没有,有比我更有知识的人可以解释如何将标题chapter*
变成sffamily
?
\documentclass[12pt, a4paper, oneside, fleqn]{report}
\headheight 28pt
\headsep 24pt
\usepackage{lmodern} % gives bold italic font
\usepackage[toc]{glossaries} % add a glossary
\makeindex
\makeglossaries
%Sectioning and headings
%------------------------
\usepackage{fancyhdr}
\fancypagestyle{plain}{ %
\fancyhf{} %clear all header/footer fields
\rhead{\sffamily{\thepage}}}
\usepackage{appendix} % allow formatting of appendix titles
\usepackage{sectsty} % put section headings in sans-serif font
\allsectionsfont{\sffamily}
\chapterfont{\LARGE\sffamily}
\makeatletter % remove hideous gap from above the chapter title
\def\@makechapterhead#1{%
%%%%\vspace*{50\p@}% %%% removed!
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\LARGE\sffamily\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\LARGE\sffamily\bfseries #1\par\nobreak
\vskip 40\p@
}}
\def\@makeschapterhead#1{%
%%%%%\vspace*{50\p@}% %%% removed!
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
%reformat some of the page titles
\renewcommand{\abstractname}{\textsf{Abstract}}
\renewcommand{\appendixpagename}{\textsf{Appendices}}
\renewcommand{\bibname}{\textsf{Bibliography}}
\renewcommand{\contentsname}{\textsf{Table Of Contents}}
\renewcommand{\listfigurename}{\textsf{List of Figures}}
\renewcommand{\listtablename}{\textsf{List of Tables}}
\makeatletter
\newcommand*{\myappendixpage}{%remove page number from the Appendix page
\begingroup
\let\ps@plain\ps@empty
\appendixpage
\endgroup}
\makeatother
\begin{document}
\pagenumbering{gobble}
\pagestyle{empty}
\renewcommand{\headrulewidth}{0pt}
%title page stuff
\begin{center}
\sffamily{\Huge{\textbf{This is the full title of my Thesis}}}
\end{center}
%end title page
%This stuff at the front with roman numbering
%--------------------------------------------
\pagestyle{plain}
\pagenumbering{roman}
\newpage
Copyright statement
\begin{abstract}
here is my abstract
\end{abstract}
\chapter*{Acknowledgements}
I'd like to acknowledge some help from some people here.
\tableofcontents
\listoffigures
\listoftables
\newglossaryentry{Term}
{
name={Term},
description={Description of my term}
}
\glsaddall
\printglossary[title=\textsf{Glossary}]
%Main thesis text with arabic numbering
%--------------------------------------
\pagenumbering{arabic}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily{\MakeUppercase{\thechapter.\ #1}}}{}}
\lhead{\leftmark}
\chead{}
\rhead{\sffamily{\thepage}}
\renewcommand{\headrulewidth}{0.1pt}
\fancyfoot{}
\chapter{Introduction with some \textit{italic text}}
Here is my chapter
%Appendices and bibliography
%---------------------------
\appendix
\myappendixpage
\chapter{My appendix}
some stuff here
\end{document}
答案1
您可以删除所有定义
%reformat some of the page titles
\renewcommand{\bibname}{\textsf{Bibliography}}
\renewcommand{\contentsname}{\textsf{Table Of Contents}}
\renewcommand{\listfigurename}{\textsf{List of Figures}}
\renewcommand{\listtablename}{\textsf{List of Tables}}
并简单地添加\sffamily
到\@makeschapterhead
:
\def\@makeschapterhead#1{%
%%%%%\vspace*{50\p@}% %%% removed!
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge\sffamily\bfseries #1\par\nobreak
\vskip 40\p@
}}
其中一些不是分段命令(abstract
和\appendixpage
),因此您必须手动重新定义它们。
为了与带星号的章节保持一致,我还将在定义中用\LARGE
进行替换:\Huge
\@makechapterhead
\def\@makechapterhead#1{%
%%%%\vspace*{50\p@}% %%% removed!
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\LARGE\sffamily\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\Huge\sffamily\bfseries #1\par\nobreak
\vskip 40\p@
}}
此外,更换线路
\printglossary[title=\textsf{Glossary}]
只需
\printglossary
否则,目录中的条目将以无衬线字体显示。
在以下 MWE 中,所有带星号和不带星号的章节均采用无衬线字体:
\documentclass[12pt, a4paper, oneside, fleqn]{report}
\headheight 28pt
\headsep 24pt
\usepackage{lmodern} % gives bold italic font
\usepackage[toc]{glossaries} % add a glossary
\makeindex
\makeglossaries
%Sectioning and headings
%------------------------
\usepackage{fancyhdr}
\fancypagestyle{plain}{ %
\fancyhf{} %clear all header/footer fields
\rhead{\sffamily{\thepage}}}
\usepackage{appendix} % allow formatting of appendix titles
\usepackage{sectsty} % put section headings in sans-serif font
\allsectionsfont{\sffamily}
\chapterfont{\LARGE\sffamily}
\makeatletter % remove hideous gap from above the chapter title
\def\@makechapterhead#1{%
%%%%\vspace*{50\p@}% %%% removed!
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\LARGE\sffamily\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\Huge\sffamily\bfseries #1\par\nobreak
\vskip 40\p@
}}
\def\@makeschapterhead#1{%
%%%%%\vspace*{50\p@}% %%% removed!
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge\sffamily\bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
%reformat some of the page titles
\renewcommand{\abstractname}{\textsf{Abstract}}
\renewcommand{\appendixpagename}{\textsf{Appendices}}
\makeatletter
\newcommand*{\myappendixpage}{%remove page number from the Appendix page
\begingroup
\let\ps@plain\ps@empty
\appendixpage
\endgroup}
\makeatother
\begin{document}
\pagenumbering{gobble}
\pagestyle{empty}
\renewcommand{\headrulewidth}{0pt}
%title page stuff
\begin{center}
\sffamily{\Huge{\textbf{This is the full title of my Thesis}}}
\end{center}
%end title page
%This stuff at the front with roman numbering
%--------------------------------------------
\pagestyle{plain}
\pagenumbering{roman}
\newpage
Copyright statement
\begin{abstract}
here is my abstract
\end{abstract}
\chapter*{Acknowledgements}
I'd like to acknowledge some help from some people here.
\tableofcontents
\listoffigures
\listoftables
\newglossaryentry{Term}
{
name={Term},
description={Description of my term}
}
\glsaddall
\printglossary
%Main thesis text with arabic numbering
%--------------------------------------
\pagenumbering{arabic}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily{\MakeUppercase{\thechapter.\ #1}}}{}}
\lhead{\leftmark}
\chead{}
\rhead{\sffamily{\thepage}}
\renewcommand{\headrulewidth}{0.1pt}
\fancyfoot{}
\chapter{Introduction with some \textit{italic text}}
Here is my chapter
%Appendices and bibliography
%---------------------------
\appendix
\myappendixpage
\chapter{My appendix}
some stuff here
\end{document}
答案2
和titlesec
:
\documentclass[12pt, a4paper, oneside, fleqn]{report}
\headheight 28pt
\headsep 24pt
\usepackage{lmodern} % gives bold italic font
\usepackage[toc]{glossaries} % add a glossary
\makeindex
\makeglossaries
%Sectioning and headings
%------------------------
\usepackage{fancyhdr}
\fancypagestyle{plain}{ %
\fancyhf{} %clear all header/footer fields
\rhead{\sffamily{\thepage}}}
\usepackage{appendix} % allow formatting of appendix titles
\usepackage{sectsty} % you can do this with titlesec too.
\allsectionsfont{\sffamily}
%\chapterfont{\LARGE\sffamily}
\usepackage{titlesec,showframe}
\titleformat{name=\chapter}[display]
{\Huge\sffamily\bfseries\filright}
{\chaptertitlename\ \thechapter.}
{1ex}
{}
\titleformat{name=\chapter,numberless}[display]
{\Huge\sffamily\bfseries\filright}
{}
{0pt}
{}
\titlespacing*{name=\chapter}{0pt}{-20pt}{40pt}
\titlespacing*{name=\chapter,numberless}{0pt}{-40pt}{40pt}
%reformat some of the page titles
\renewcommand{\abstractname}{\textsf{Abstract}}
\renewcommand{\appendixpagename}{\textsf{Appendices}}
\makeatletter
\newcommand*{\myappendixpage}{%remove page number from the Appendix page
\begingroup
\let\ps@plain\ps@empty
\appendixpage
\endgroup}
\makeatother
\begin{document}
\pagenumbering{gobble}
\pagestyle{empty}
\renewcommand{\headrulewidth}{0pt}
%title page stuff
\begin{center}
\sffamily{\Huge{\textbf{This is the full title of my Thesis}}}
\end{center}
%end title page
%This stuff at the front with roman numbering
%--------------------------------------------
\pagestyle{plain}
\pagenumbering{roman}
\newpage
Copyright statement
\begin{abstract}
here is my abstract
\end{abstract}
\chapter*{Acknowledgements}
I'd like to acknowledge some help from some people here.
\tableofcontents
\listoffigures
\listoftables
\newglossaryentry{Term}
{
name={Term},
description={Description of my term}
}
\glsaddall
\printglossary
%Main thesis text with arabic numbering
%--------------------------------------
\pagenumbering{arabic}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily{\MakeUppercase{\thechapter.\ #1}}}{}}
\lhead{\leftmark}
\chead{}
\rhead{\sffamily{\thepage}}
\renewcommand{\headrulewidth}{0.1pt}
\fancyfoot{}
\chapter{Introduction with some \textit{italic text}}
Here is my chapter
%Appendices and bibliography
%---------------------------
\appendix
\myappendixpage
\chapter{My appendix}
some stuff here
\end{document}