之前我问过一个问题,如何将 的标题List of Acronyms and Symbols
与 的标题相匹配List of table
(而不是章节标题)。Nicola 通过以下方式解决了这个问题标题缩写列表和词汇表列表的格式链接。然而,现在出现了一种相反的问题,我的Glossary
标题与等的样式相同List of Symbols
,但我希望它与我的章节和索引标题相同(较小且居中),因为它位于末尾。我附上了一个,MWE
它也反映了 Nicola 发送的代码来解决我之前的问题。我希望这是人为可以做到的 :)
\documentclass[12pt]{report}
%%%%%%%%%%%%%% For page header/footer
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\fancyhf{}
\setlength{\headheight}{15pt}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\lhead{\bfseries{\rightmark}}
\rhead{\bfseries{\thepage}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{makeidx}
\usepackage{sectsty}
\allsectionsfont{\bfseries}
\chapterfont{\centering\Large}
\sectionfont{\normalsize}
\subsectionfont{\normalsize}
\usepackage[subfigure]{tocloft}
\usepackage{tocloft}
\renewcommand{\cftchappresnum}{Chapter }
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{7em}
\newcommand*\updatechaptername{%
\addtocontents{toc}{\protect\renewcommand*\protect\cftchappresnum{Appendix }}
}
\makeindex
\usepackage[nogroupskip,nonumberlist,acronym]{glossaries}
\newglossary[slg]{symbolslist}{syi}{syg}{List of Symbols}
\makeglossaries
% Code provided by Nicola Talbot to make heading of List of Acronyms and
% List of Symbols same as heading of List of Tables.
\renewcommand{\glossarysection}[2][\theglstoctitle]{%
\def\theglstoctitle{#2}%
\vspace{\cftbeforelottitleskip}%
\par\noindent
{\cftlottitlefont #2}{\cftafterlottitle}%
\vskip\cftafterlottitleskip
}
% % % % % % % % % % % % Glossary Entries % % % % % % % % % % % %
\newacronym{sa}{SA}{sample acronym}
\newglossaryentry{Pi}{
name=$\pi$,
description={A mathematical constant whose value is the ratio of any circle's circumference to its diameter.},
sort=symbpi, type=symbolslist
}
\newglossaryentry{glos:ia}{
name=Integer Ambiguity,
description={The unknown number of whole carrier phase cycles between the user and the satellite at the start of tracking (Sometimes ambiguity for short).}
}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\usepackage{subfigure}
\begin{document}
\tableofcontents
\clearpage
\listoftables
\clearpage
\printglossary[type=\acronymtype,style=long,title=List of Acronyms \& Initialisms]
\clearpage
\printglossary[type=symbolslist,style=long] %Print list of symbols
\include{Sample}
\chapter{Sample}
This is my \gls{sa} and I can use it again. This is a symbol \gls{Pi}. This document\index{document} also has an index\index{index}.
\begin{table}
\caption{Sample Table}
\end{table}
\updatechaptername
\clearpage
\glsaddall
\printglossary[] % Print list of symbols
\clearpage
\printindex
\end{document}
答案1
您只需要\glossarysection
在最终之前再次重新定义\printglossary
,以便它现在使用\chapter*
:
\documentclass[12pt]{report}
\usepackage{makeidx}
\usepackage{sectsty}
\allsectionsfont{\bfseries}
\chapterfont{\centering\Large}
\sectionfont{\normalsize}
\subsectionfont{\normalsize}
\usepackage[subfigure]{tocloft}
\usepackage{tocloft}
\renewcommand{\cftchappresnum}{Chapter }
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{7em}
\newcommand*\updatechaptername{%
\addtocontents{toc}{\protect\renewcommand*\protect\cftchappresnum{Appendix }}
}
\makeindex
\usepackage[nogroupskip,nonumberlist,acronym]{glossaries}
\newglossary[slg]{symbolslist}{syi}{syg}{List of Symbols}
\makeglossaries
% section heading for glossaries in the front matter:
\renewcommand{\glossarysection}[2][\theglstoctitle]{%
\def\theglstoctitle{#2}%
\vspace{\cftbeforelottitleskip}%
\par\noindent
{\cftlottitlefont #2}{\cftafterlottitle}%
\vskip\cftafterlottitleskip
}
% % % % % % % % % % % % Glossary Entries % % % % % % % % % % % %
\newacronym{sa}{SA}{sample acronym}
\newglossaryentry{Pi}{
name=$\pi$,
description={A mathematical constant whose value is the ratio of any circle's circumference to its diameter.},
sort=symbpi, type=symbolslist
}
\newglossaryentry{glos:ia}{
name=Integer Ambiguity,
description={The unknown number of whole carrier phase cycles between the user and the satellite at the start of tracking (Sometimes ambiguity for short).}
}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\usepackage{subfigure}
\begin{document}
\tableofcontents
\clearpage
\listoftables
\clearpage
\printglossary[type=\acronymtype,style=long,title=List of Acronyms \& Initialisms]
\clearpage
\printglossary[type=symbolslist,style=long] %Print list of symbols
\chapter{Sample}
This is my \gls{sa} and I can use it again. This is a symbol \gls{Pi}. This document\index{document} also has an index\index{index}.
\begin{table}
\caption{Sample Table}
\end{table}
\updatechaptername
\clearpage
\glsaddall
% redefine glossary section heading
\renewcommand{\glossarysection}[2][]{\chapter*{#1}}
\printglossary[] % Print list of symbols
\clearpage
\printindex
\end{document}
得出的结果为:
(您可能想要使用nopostdot
包选项来抑制多余的最后句号。)
如果您还想将词汇表添加到目录中,则需要调整代码以包含\addcontentsline
:
\renewcommand{\glossarysection}[2][\theglstoctitle]{%
\def\theglstoctitle{#2}%
\chapter*{#2}%
\addcontentsline{toc}{chapter}{#1}%
}
或者
\renewcommand{\glossarysection}[2][\theglstoctitle]{%
\def\theglstoctitle{#2}%
\chapter*{#2}%
\addcontentsline{toc}{chapter}{\numberline{}#1}%
}
要更新页眉,您可以使用\markboth
。例如:
\renewcommand{\glossarysection}[2][\theglstoctitle]{%
\def\theglstoctitle{#2}%
\chapter*{#2}%
\addcontentsline{toc}{chapter}{\numberline{}#1}%
\markboth{#1}{#1}%
}
或(对于大写标题):
\renewcommand{\glossarysection}[2][\theglstoctitle]{%
\def\theglstoctitle{#2}%
\chapter*{#2}%
\addcontentsline{toc}{chapter}{\numberline{}#1}%
\markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}%
}
编辑:
假设此时文档中没有更多带编号的章节。在这种情况下,最简单的解决方案可能是使用\chapter
而不是\chapter*
通过更改计数器来抑制编号secnumdepth
。这将确保词汇表的行为方式与其他章节相同。例如:
\renewcommand{\glossarysection}[2][\theglstoctitle]{%
\def\theglstoctitle{#2}%
\setcounter{secnumdepth}{-1}%
\chapter[#1]{#2}%
}