更改缩略词标题以匹配表格列表/图表列表(词汇表)

更改缩略词标题以匹配表格列表/图表列表(词汇表)

我正在使用 Overleaf 撰写论文。我想格式化我的表格列表/图片列表并将其添加到目录中。以下大部分代码都是从本论坛的其他答案中复制粘贴的。

但是,现在我需要添加一个缩写列表,我希望此列表标题的样式与表格列表/图表列表的样式相似。老实说,我不知道该怎么做才能改变 LoF/LoT 的样式,但我想对首字母缩略词做同样的事情。我使用以下代码来实现这一点。

\documentclass[12pt, a4paper, openany]{book} %oneside
\textheight23cm \textwidth15cm

\usepackage{fancyhdr}
    

    \pagestyle{fancy}
    \fancyhf{}% Clear header/footer
    \fancyhead[L]{\nouppercase\leftmark}
    \fancyhead[R]{\thepage}

\usepackage[acronym, toc]{glossaries}

\makeglossaries
\newacronym{abms}{ABMS}{Agent-Based Modeling and Simulation}
\renewcommand{\acronymname}{List of Abbreviations}

\usepackage{titletoc}
\usepackage{tocloft}
\usepackage[nottoc,numbib]{tocbibind}

% Headings for every page of ToC, LoF and Lot
\newcommand\tocheading{\par\bigskip\MakeUppercase{\chaptername}\hfill Page\par}
\newcommand\lofheading{\par\bigskip\figurename\hfill Page\par}
\newcommand\lotheading{\par\bigskip\MakeUppercase{\tablename}\hfill Page\par}

% Centering titles for the ToC, Lof and Lot
\renewcommand{\cfttoctitlefont}{\hfill\normalfont\MakeUppercase}
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand{\cftloftitlefont}{\hfill\normalfont\MakeUppercase}
\renewcommand{\cftafterloftitle}{\hfill}
\renewcommand{\cftlottitlefont}{\hfill\normalfont\MakeUppercase}
\renewcommand{\cftafterlottitle}{\hfill}

\begin{document}
\clearpage
\tableofcontents

\clearpage
\printglossaries

\clearpage
\addtocontents{lof}{\lofheading}% add heading to the first page in LoF
\listoffigures
\clearpage
\addtocontents{lot}{\lotheading}% add heading to the first page in LoT
\listoftables
\end{document}

答案1

欢迎使用 Latex!这是实现这一目标的方法。我对您的代码做了一些更改。我需要解释其中的一些更改。在听完这些解释之后,您可能仍然感到困惑。我建议您花点时间阅读一些基本的 latex 文档。这可能会对您有很大帮助:

编辑:我需要更正第三项中的一条陈述。见下文:

  1. 如果你想要一份单面文件,你应该使用oneside选项而不是openany
  2. 我生成了真实的图形和表格,您不需要手动向 lof 或 lot 添加条目。
  3. 由于您使用\makeglossaries,因此glossaries包将使用makeindex(即 CLI 应用程序)对条目进行排序。通常,每次编译文档时,您都需要手动运行 makeindex(更多信息请参阅词汇表文档第 21 页)。如果您不知道这是什么意思。您应该添加automakeglossaries包选项。并且命令应该在定义完\makeglossaries所有命令之后添加\newacronym。这是错误的。实际上,相反的方法是正确的,这意味着应该在定义完\makeglossaries所有命令之前添加命令。\newacronym
  4. 因为你使用了fancyhdr包,所以你的headheight太小了。所以我设置\setlength{\headheight}{15pt}

一些建议:您可以使用geometry包来设置边距,而不是设置\textheight23cm\textwidth15cm。因为这对新用户来说简单而直接。

根据您的评论,我在这里写答案:

  1. 在 Overleaf 上,无法使用 CLI 执行命令。但 overleaf 会帮你搞定一切。你可以看看这个关联

  2. 要了解该命令的含义,你可以转到tocloft文档第 23 页。这两个命令的\renewcommand{\cfttoctitlefont}{\hfill\normalfont\MakeUppercase}作用\renewcommand{\cftaftertoctitle}{\hfill}类似,都\hfill\normalfont\MakeUppercase your header\hfill意味着将“您的页眉”居中,并使用普通字体和大写字母。

  3. \makeglossary命令没有任何参数来设置“缩写列表”标题。我是通过 来设置的\printglossary[type=\acronymtype,title={\centering\normalsize\normalfont\MakeUppercase{\acronymname}},toctitle=\acronymname]。要查看有关此内容的更多信息,您可以查看文档在第182页。

\documentclass[12pt,a4paper,oneside]{book}% oneside option added
\textheight23cm \textwidth15cm % better use geometry package (e.g. \usepackage[margin=2cm]{geometry})
\usepackage{mwe} %create fake figure
\usepackage{lipsum} %create fake text

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}% Clear header/footer
\setlength{\headheight}{15pt}
\fancyhead[L]{\nouppercase\leftmark}
\fancyhead[R]{\thepage}

\usepackage[acronym,toc,automake]{glossaries}
\makeglossaries
\newacronym{abms}{ABMS}{Agent-Based Modeling and Simulation}
\renewcommand{\acronymname}{List of Abbreviations}

\usepackage{titletoc}
\usepackage{tocloft}
\usepackage[nottoc,numbib]{tocbibind}

% Centering titles for the ToC, Lof and Lot
\renewcommand{\cfttoctitlefont}{\hfill\normalfont\MakeUppercase}
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand{\cftloftitlefont}{\hfill\normalfont\MakeUppercase}
\renewcommand{\cftafterloftitle}{\hfill}
\renewcommand{\cftlottitlefont}{\hfill\normalfont\MakeUppercase}
\renewcommand{\cftafterlottitle}{\hfill}

\begin{document}
\clearpage
\tableofcontents
\clearpage

\listoffigures
\clearpage

\listoftables

\printglossary[type=\acronymtype,title={\centering\normalsize\normalfont\MakeUppercase{\acronymname}},toctitle=\acronymname]

\chapter{Foo}
This is an example of abbreviation \gls{abms}.

\begin{figure}[ht]
    \centering
    \includegraphics[scale=0.5]{example-image}
    \caption{Figure Caption}
    \label{fig:my_label}
\end{figure}

\lipsum[2]
\begin{table}[ht]
    \centering
    \caption{Table Caption}
    \label{tab:my_label}
    \begin{tabular}{lccc}
        \hline
        items&a&b&c\\\hline
        item1&1&2&3\\
        item2&4&5&6\\\hline
    \end{tabular}
\end{table}
\end{document}

在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

相关内容