我对 glossaries-extra 包有几个问题,我想自定义它们。您可以在下面找到代码和相应的输出:
- 我想制作像上面的图片列表一样的缩写列表。目前存在以下差异:
1.1 可以看到,点间距不一样,而且点并不粗体。
1.2 缩写前面有一个缩进,这是我所不希望的。
1.3 我希望缩写的描述能够右对齐。
1.4 我想将垂直间距改为1ex
(如图列表所示)
我知道您可以使用 更改现有的词汇表样式\newglossarystyle
,但我找不到合适的命令。我使用 样式listdotted
。我可以使用以下代码自定义我的要点吗?
\newglossarystyle{mylist}{
\setglossarystyle{listdotted} % base this style on the listdotted style
% change goes here:
\renewcommand{}{}
}
您可以在这里找到所有预定义的样式,但我认为listdotted
我的工作最少?:https://www.dickimaw-books.com/gallery/glossaries-styles/
- 我的第二个问题是文本中使用缩写。在输出中,显示了目标和实际状态。
我希望只有第一次使用缩写时,缩写形式才以粗体显示。所有后续缩写都不应以粗体显示。
因此:第一次使用缩写时,全称以粗体打印首字母,简称以括号和粗体打印。
第二次使用时,仅使用缩写形式,而不使用粗体文本。
在缩写列表中,简称应该用粗体表示,并单独定义描述(见代码)。
我希望它是可以理解的并且有人可以帮助我进行定制!
\documentclass[a4paper, 12pt]{article}
\usepackage{graphicx}
\usepackage[left=2.5cm, right=2.5cm, top=2.75cm, bottom=2cm]{geometry}
\usepackage{tocbasic}
\usepackage[ngerman]{babel}
\usepackage[hidelinks]{hyperref}
\usepackage[toc,nogroupskip,xindy,style=listdotted]{glossaries-extra}
% graphics
\graphicspath{ {./images/} }
% set default font
\usepackage{fontspec}
\setmainfont{Arial}
\newfontfamily\schola{TeX Gyre Schola}
\usepackage{setspace}
\onehalfspacing
% set default indent
\setlength{\parindent}{0pt}
% list of figures
\DeclareTOCStyleEntries[
beforeskip=1ex,
linefill=\bfseries\dotfill,
pagenumberformat=\bfseries\schola,
pagenumberbox=\pagenumberbox,
entrynumberformat=\bfseries\figurenumberformat,
numwidth=7em,
indent=0em,
]{tocline}{figure}
\newcommand*\pagenumberbox[1]{\mbox{\hspace{0em}#1}}
\newcommand*{\figurenumberformat}[1]{\mbox{Abbildung #1}:}
% list of abbreviations
\makeglossaries
\newabbreviation
[description={Federal Bureau of Investigation -- Investigative and National Security Components}]
{fbi}{\textbf{FBI-INC}}{\textbf{F}ederal \textbf{B}ureau of \textbf{I}nvestigation -- \textbf{I}nvestigative and \textbf{N}ational Security \textbf{C}omponents}
\newabbreviation
[description={LongDescriptionThatExtendsIntoTheMargin}]
{usa}{\textbf{USA}}{\textbf{U}nited \textbf{S}tates of \textbf{A}merica}
\newabbreviation
[description={United States}]
{us}{\textbf{US}}{\textbf{U}nited \textbf{S}tates}
\begin{document}
% Table of figures
\addcontentsline{toc}{section}{\listfigurename}
\listoffigures
% List of abbreviations
\printglossary[title={Abkürzungsverzeichnis}]
% TARGET-ACTUAL comparison
\section{TARGET}
First use: The \textbf{F}ederal \textbf{B}ureau of \textbf{I}nvestigation -- \textbf{I}nvestigative and \textbf{N}ational Security \textbf{C}omponents (\textbf{FBI-INC}) protects the \textbf{U}nited \textbf{S}tates (\textbf{US}) (or \textbf{U}nited \textbf{S}tates of \textbf{A}merica (\textbf{USA})) through investigations and national security.
\vspace{\baselineskip}
Second use: The FBI-INC protects the US (or USA) through investigations and national security.
\section{ACTUAL}
First use: The \gls{fbi} protects the \gls{us} (or \gls{usa}) through investigations and national security.
\vspace{\baselineskip}
Second use: The \gls{fbi} protects the \gls{us} (or \gls{usa}) through investigations and national security.
\begin{figure}[ht]
\centering
\includegraphics[height=1cm]{overleaf-logo}
\caption{Caption}
\end{figure}
\end{document}
答案1
您几乎已经解决了有关列表的问题的第一部分你自己的答案唯一缺少的是,你可以通过重新定义环境来控制垂直theglossary
分离
\renewenvironment{theglossary}%
{\glslistinit\begin{description}[itemsep=1ex,parsep=0ex]}%
{\end{description}}
使用enumitem
为了方便。
我不太相信重新定义\gls
是特别有效的,或者确实是一个好主意。更理想的方法是创建一个abbreviationstyle
基于long-short
样式的自定义,在第一次出现时明确使用粗体字体表示缩写。
\newabbreviationstyle{mystyle}{%
\GlsXtrUseAbbrStyleSetup{long-short}%
}{%
\GlsXtrUseAbbrStyleFmts{long-short}%
\renewcommand*{\glsfirstabbrvfont}[1]{\textbf{##1}}%
}
该方法类似glossaries
,\firstacronymfont
而是重新定义。
\documentclass[a4paper, 12pt]{article}
\usepackage{graphicx}
\usepackage[left=2.5cm, right=2.5cm, top=2.75cm, bottom=2cm]{geometry}
\usepackage{tocbasic}
\usepackage{enumitem}
\usepackage[toc,nogroupskip,xindy,style=listdotted]{glossaries-extra}
\usepackage{fontspec}
\setmainfont{Arial}
\newfontfamily\schola{TeX Gyre Schola}
\usepackage{setspace}
\onehalfspacing
\setlength{\parindent}{0pt}
\DeclareTOCStyleEntries[
beforeskip=1ex,
linefill=\bfseries\dotfill,
pagenumberformat=\bfseries\schola,
pagenumberbox=\pagenumberbox,
entrynumberformat=\bfseries\figurenumberformat,
numwidth=7em,
indent=0em,
]{tocline}{figure}
\newcommand*\pagenumberbox[1]{\mbox{\hspace{0em}#1}}
\newcommand*{\figurenumberformat}[1]{\mbox{Abbildung #1}:}
\newglossarystyle{mystyle}{
\setglossarystyle{list}
\renewcommand*{\glossentry}[2]{
\item[\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}]
\textbf{\dotfill}
\raggedleft\glossentrydesc{##1}
}
\renewenvironment{theglossary}%
{\glslistinit\begin{description}[itemsep=1ex,parsep=0ex]}%
{\end{description}}
}
\newabbreviationstyle{mystyle}{%
\GlsXtrUseAbbrStyleSetup{long-short}%
}{%
\GlsXtrUseAbbrStyleFmts{long-short}%
\renewcommand*{\glsfirstabbrvfont}[1]{\textbf{##1}}%
}
\setabbreviationstyle{mystyle}
\makeglossaries
\newabbreviation
[description={Federal Bureau of Investigation -- Investigative and National Security Components}]
{fbi}{FBI-INC}{\textbf{F}ederal \textbf{B}ureau of \textbf{I}nvestigation -- \textbf{I}nvestigative and \textbf{N}ational Security \textbf{C}omponents}
\newabbreviation
[description={LongDescriptionThatExtendsIntoTheMargin}]
{usa}{USA}{\textbf{U}nited \textbf{S}tates of \textbf{A}merica}
\newabbreviation
[description={United States}]
{us}{US}{\textbf{U}nited \textbf{S}tates}
\begin{document}
\listoffigures
\printglossary[style=mystyle,title={Abkürzungsverzeichnis}]
\section{TARGET}
First use: The \textbf{F}ederal \textbf{B}ureau of \textbf{I}nvestigation -- \textbf{I}nvestigative and \textbf{N}ational Security \textbf{C}omponents (\textbf{FBI-INC}) protects the \textbf{U}nited \textbf{S}tates (\textbf{US}) (or \textbf{U}nited \textbf{S}tates of \textbf{A}merica (\textbf{USA})) through investigations and national security.
\vspace{\baselineskip}
Second use: The FBI-INC protects the US (or USA) through investigations and national security.
\section{ACTUAL}
First use: The \gls{fbi} protects the \gls{us} (or \gls{usa}) through investigations and national security.
\vspace{\baselineskip}
Second use: The \gls{fbi} protects the \gls{us} (or \gls{usa}) through investigations and national security.
\begin{figure}[htbp]
\caption{Caption 1}
\end{figure}
\begin{figure}[htbp]
\caption{Caption 2}
\end{figure}
\end{document}
答案2
我找到了解决我所描述的问题的方法:
对于第一个问题:
\newglossarystyle{mystyle}{
\setglossarystyle{list}
\renewcommand*{\glossentry}[2]{
\item[\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}]
\textbf{\dotfill}
\raggedleft\glossentrydesc{##1}
}
}
与\printglossary[style=mystyle,title={Abkürzungsverzeichnis}]
之后\begin{document}
但:我无法将垂直间距修改为1ex
。
第二个问题可以用这个命令修复:
\renewcommand*{\gls}[1]{%
\ifglsused{#1}%
{\glslink{#1}{\glsentryshort{#1}}}%
{\glsunset{#1}\glslink{#1}{\glsentrylong{#1} (\textbf{\glsentryshort{#1}})}}%
}
如您所见,目标现在与实际匹配: