背景
我正在创建数学入门工作表。我只需要有关fancyhdr
under% [ pkg - page format ]
和\tableofcontents
under的帮助% [ document ]
。以下是示例:
% [ file: maths-primer.tex ] =======================================================================
% [ pkg - document format ] ------------------------------------------------------------------------
\documentclass[11pt, table, dvipsnames]{extarticle}
\usepackage{extsizes, advdate}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
% [ pkg - page format ] ----------------------------------------------------------------------------
\usepackage{geometry}
\usepackage{titling, titlesec, fancyhdr}
\geometry{
a4paper,
total={2.54cm,25.7cm},
textwidth=14.3cm,
top=4cm,
bottom=4cm
}
\titleformat{\section}[hang]{\filcenter\scshape\normalsize}{}{1pt}{}
\titleformat{\subsection}[hang]{\filcenter\scshape\LARGE}{}{1pt}{}
\renewcommand{\subsectionmark}[1]{\markboth{#1}{}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\thepage \ \textbar \quad \textsc{Maths Primer}}
\fancyhead[R]{\scshape\leftmark}
\renewcommand{\headrulewidth}{0pt}
% [ pkg - maths presentation ] ---------------------------------------------------------------------
\usepackage{amsmath, amsthm, amssymb, array, calc, thmtools, bm, mathtools}
\setlength{\tabcolsep}{2em}
\renewcommand{\arraystretch}{1.5}
% [ pkg - graphics presentation ] ------------------------------------------------------------------
\definecolor{paleGB}{HTML}{F6F8FA}
\definecolor{darkGB}{HTML}{E9EEF3
% [ document ] -------------------------------------------------------------------------------------
\color{black!88}
\renewcommand*{\contentsname}{Table of Contents}
\begin{document}
\setlength{\parindent}{0pt}% Remove paragraph indentation
\begingroup
\footnotesize
% [title] block ...
% -------------------------------------------------------------------------------------------[S]
\begin{center}
\rmfamily
\Large{\textsc{Maths Primer}}
{\fontsize{9pt}{10pt}\selectfont \tableofcontents}
\end{center}
% -------------------------------------------------------------------------------------------[E]
\newpage
% section: Deterministic Maths /////////////////////////////////////////////////////////////////
\rmfamily
\section{Deterministic Maths}
\subsection{Arithmetic: Fundamentals}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: [ geometry ]
\rmfamily
\subsection{Geometry: Fundamentals}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Geometry: Trigonometry}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Geometry: Plane-Analytic Geometry}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Geometry: Solid-Analytic Geometry}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: [ algebra ]
\rmfamily
\subsection{Algebra: Time Algebra}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Algebra: Linear Algebra}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Algebra: Space Algebra}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: [ mathematical analysis ]
\rmfamily
\subsection{Mathematical Analysis: Fundamentals}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Mathematical Analysis: Differential Calculus}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Mathematical Analysis: Integral Calculus}
\noindent
\textbf{Essence:} \blintext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Mathematical Analysis: Series}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Mathematical Analysis: Differential Equations}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: Foundational Maths //////////////////////////////////////////////////////////////////
\rmfamily
\section{Foundational Maths}
\subsection{major: minor}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: Stochastic Maths ////////////////////////////////////////////////////////////////////
\rmfamily
\section{Stochastic Maths}
\subsection{major: minor}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: Discrete Maths //////////////////////////////////////////////////////////////////////
\rmfamily
\section{Discrete Maths}
\subsection{major: minor}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\endgroup
\end{document}
问题
当目录标题出现在文档页眉的右上方时,其字体大小与页眉左侧的字体大小(由序言指定)不匹配fancyhead
。为什么会发生这种情况?我该如何解决?
答案1
最简单的解决方案是删除右标题中的大写字母,并使用
\fancyhead[R]{\scshape\nouppercase{\leftmark}}
答案2
\tableofcontents
在内部定义如下extarticle.cls
:
\newcommand\tableofcontents{%
\section*{\contentsname
\@mkboth{%
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
\@starttoc{toc}%
}
它设置了一个未编号的\section
,并使用 设置标题\MakeUppercase
。重新定义它以使用\textsc
(或使用 进行修补etoolbox
):
% [ file: maths-primer.tex ] =======================================================================
% [ pkg - document format ] ------------------------------------------------------------------------
\documentclass[11pt, table, dvipsnames]{extarticle}
\usepackage{extsizes, advdate}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\makeatletter
% Update ToC to use \textsc in header, not \MakeUppercase
\renewcommand{\tableofcontents}{%
\section*{%
\contentsname
\@mkboth{\textsc{\contentsname}}{\textsc{\contentsname}}%'
}
\@starttoc{toc}%
}
\makeatother
% [ pkg - page format ] ----------------------------------------------------------------------------
\usepackage{geometry, xcolor}
\usepackage{titling, titlesec, fancyhdr}
\geometry{
a4paper,
total={2.54cm,25.7cm},
textwidth=14.3cm,
top=4cm,
bottom=4cm
}
\titleformat{\section}[hang]{\filcenter\scshape\normalsize}{}{1pt}{}
\titleformat{\subsection}[hang]{\filcenter\scshape\LARGE}{}{1pt}{}
\renewcommand{\subsectionmark}[1]{\markboth{#1}{}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\thepage \ \textbar \quad \textsc{Maths Primer}}
\fancyhead[R]{\scshape\leftmark}
\renewcommand{\headrulewidth}{0pt}
% [ pkg - maths presentation ] ---------------------------------------------------------------------
\usepackage{amsmath, amsthm, amssymb, array, calc, thmtools, bm, mathtools}
\setlength{\tabcolsep}{2em}
\renewcommand{\arraystretch}{1.5}
% [ pkg - graphics presentation ] ------------------------------------------------------------------
\definecolor{paleGB}{HTML}{F6F8FA}
\definecolor{darkGB}{HTML}{E9EEF3}
% [ document ] -------------------------------------------------------------------------------------
\color{black!88}
\renewcommand*{\contentsname}{Table of Contents}
\begin{document}
\setlength{\parindent}{0pt}% Remove paragraph indentation
\begingroup
\footnotesize
% [title] block ...
% -------------------------------------------------------------------------------------------[S]
\begin{center}
\rmfamily
\show\tableofcontents
\Large{\textsc{Maths Primer}}
{\fontsize{9pt}{10pt}\selectfont \tableofcontents}
\end{center}
% -------------------------------------------------------------------------------------------[E]
\newpage
% section: Deterministic Maths /////////////////////////////////////////////////////////////////
\rmfamily
\section{Deterministic Maths}
\subsection{Arithmetic: Fundamentals}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: [ geometry ]
\rmfamily
\subsection{Geometry: Fundamentals}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Geometry: Trigonometry}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Geometry: Plane-Analytic Geometry}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Geometry: Solid-Analytic Geometry}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: [ algebra ]
\rmfamily
\subsection{Algebra: Time Algebra}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Algebra: Linear Algebra}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Algebra: Space Algebra}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: [ mathematical analysis ]
\rmfamily
\subsection{Mathematical Analysis: Fundamentals}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Mathematical Analysis: Differential Calculus}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Mathematical Analysis: Integral Calculus}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Mathematical Analysis: Series}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
\rmfamily
\subsection{Mathematical Analysis: Differential Equations}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: Foundational Maths //////////////////////////////////////////////////////////////////
\rmfamily
\section{Foundational Maths}
\subsection{Major: Minor}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: Stochastic Maths ////////////////////////////////////////////////////////////////////
\rmfamily
\section{Stochastic Maths}
\subsection{Major: Minor}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\newpage
% section: Discrete Maths //////////////////////////////////////////////////////////////////////
\rmfamily
\section{Discrete Maths}
\subsection{Major: Minor}
\noindent
\textbf{Essence:} \blindtext
% ////// [ PARAGRAPH END ]
\endgroup
\end{document}