借助本网站现有答案,我设法为我的文档添加了一个词汇表。在glossaries
文档中(http://texdoc.net/texmf-dist/doc/latex/glossaries/glossaries-user.pdf)我读到了关于定制词汇表的内容,特别是关于long3col
样式的内容:
long3col
The long3col style is like long but has three columns. The first
column contains the entry’s name, the second column contains
the description and the third column contains the number list.
我的问题如下:是否可以自定义long3col
词汇表样式,使得每个术语都有两个相应的描述,一个用于第二列(即定义),一个用于第三列(即示例或公式)?那么,1)这可能吗?
2)如果可以定制,那么实现定制的最佳方法是什么?
此 MWE 仅供方便之用。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[style=altlist]{glossaries}
% \usepackage{glossary-mcols}
% \renewcommand*{\glsmcols}{3}
% \setglossarystyle{mcolindex}
\makeglossaries
\newglossaryentry{latex}
{
name=latex,
description={Is a mark up language specially suited
for scientific documents}
}
\newglossaryentry{maths}
{
name=mathematics,
description={Mathematics is what mathematicians do}
}
\title{How to create a glossary}
\author{ }
\date{ }
\begin{document}
\maketitle
The \Gls{latex} typesetting markup language is specially suitable
for documents that include \gls{maths}.
\clearpage
\printglossaries
\end{document}
答案1
最快的方法是重新使用long3col
新词汇表样式中的样式,比如说使用六个用户doubledescriptioncol
键之一user1
......。user6
要获取用户按键的内容,user1
请应用命令\glsuseri
等,即将与按键编号相对应的小写罗马数字附加到命令名称glsuser
。
\newglossarystyle{doubledescriptioncol}{%
\setglossarystyle{long3col}% base this style on the long3col style
% Now change the glossary environment, i.e. the `longtable` wrapper.
\renewenvironment{theglossary}{% Change the table type --> 3 columns
\begin{longtable}{lp{0.6\glsdescwidth}>{\centering\arraybackslash}p{2cm}}}%
{\end{longtable}}%
%
% This is used as the header of the `longtable`.
\renewcommand*{\glossaryheader}{% Change the table header
\bfseries Sign & \bfseries Description & \bfseries Formula \\
\hline
\endhead}
%The most important command: What is shown in which style:
\renewcommand*{\glossentry}[2]{% Change the displayed items
\glstarget{##1}{\glossentryname{##1}} % link the target
& \glossentrydesc{##1}% Description % Enter the description
& \glsdisablehyper\glsuseri{##1} \tabularnewline % Fetch the user1 key content.
}
}
以下是 MWE:
\documentclass{article}
\usepackage{array}
\usepackage[utf8]{inputenc}
\usepackage{glossaries}
\makeglossaries
\newglossarystyle{doubledescriptioncol}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
\begin{longtable}{lp{0.6\glsdescwidth}>{\centering\arraybackslash}p{2cm}}}%
{\end{longtable}}%
%
\renewcommand*{\glossaryheader}{% Change the table header
\bfseries Sign & \bfseries Description & \bfseries Formula \\
\hline
\endhead}
\renewcommand*{\glossentry}[2]{% Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glossentrydesc{##1}% Description
& \glsuseri{##1} \tabularnewline
}
}
\newglossaryentry{Einstein}
{
name=Einstein,
description={Great Scientist},
user1={\ensuremath{E=mc^{2}}}
}
\newglossaryentry{spherevolume}
{
name={Sphere volume},
description={Volume of a sphere in 3-D space},
user1={\ensuremath{V=\frac{4}{3} \pi r^{3}}}
}
\title{How to create a glossary}
\author{ }
\date{ }
\begin{document}
\maketitle
\glsaddall
\clearpage
\setglossarystyle{doubledescriptioncol}
\printglossaries
\end{document}