\usepackage{glossaries} 包含 3 列

\usepackage{glossaries} 包含 3 列

我需要在词汇表中增加额外的栏目。

我的应用程序是带有以下符号的列表

  1. 象征
  2. 描述
  3. 单位
\documentclass{article}
\usepackage{glossaries}


\makeglossaries

\newglossaryentry{mwe}{name=MWE, description={Minimum Working Example}}

% the previous line should have some extra field, or i could define my own command.
% Something that would envolve description={ {some text} && {some unit}}

\begin{document}

\printglossaries

\clearpage

This is the call to the \Gls{mwe}

\end{document}

更新:如果您正在运行 ubuntu < 12.04,您需要更新您的软件包。(请参阅这里

答案1

词汇表条目最多可以有六个用户字段。我们将其用作user1单位,因此条目将构造为

\newglossaryentry{A}{%
name={foo},%
description={bar},%
user1={cm}%
}

然后我们需要一种新的样式来使用新字段。手册中描述了如何定义新样式,重要的是要知道可以通过访问用户字段\glsentryuseri{##1}。要基于 来创建样式longtable,我们这样做(大部分内容是从手册中复制的):

\documentclass[a4paper,10pt]{article}
\usepackage{glossaries}
\makeglossaries

\newglossaryentry{A}{%
name={foo},%
description={bar},%
user1={cm}%
}

\newglossaryentry{B}{%
name={AAPL},%
description={apples},%
user1={box}%
}

\newglossaryentry{C}{%
name={BTR},%
description={books to read},%
user1={LoC}%
}

\newglossaryentry{D}{%
name={BTRTIO},%
description={books to read that I own},%
user1={shelf},%
parent={C}
}

\newglossarystyle{aiaostyle}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
 {\begin{longtable}{lp{\glsdescwidth}cp{\glspagelistwidth}}}%
 {\end{longtable}}%
% Set the table’s header: title row
\renewcommand*{\glossaryheader}{%
 \bfseries Term & \bfseries Description & 
 \bfseries Units & \bfseries Page List
 \\\endhead}%
% No table header:
\renewcommand*{\glossaryheader}{}%
% No heading between groups:
 \renewcommand*{\glsgroupheading}[1]{}%
% Main (level 0) entries displayed in a row optionally numbered:
 \renewcommand*{\glossaryentryfield}[5]{%
    \glstarget{##1}{##2}% Name
    & ##3% Description
    & \glsentryuseri{##1}% Units
    & ##5% Page list
    \\% end of row
 }%
% Similarly for sub-entries (no sub-entry numbers):
\renewcommand*{\glossarysubentryfield}[6]{%
    % ignoring first argument (sub-level)
    \glstarget{##2}{##3}% Name
    & ##4% Description
    & \glsentryuseri{##2}% Units
    & ##6% Page list
    \\% end of row
 }%
% Nothing between groups:
\renewcommand*{\glsgroupskip}{}%
}

\begin{document}
\null
\glsaddall

\glossarystyle{aiaostyle}
\setlength{\glsdescwidth}{0.5\textwidth}
\setlength{\glspagelistwidth}{0.1\textwidth}
\printglossary

\end{document}

词汇表将有longtable四列,其中第三列c将包含该字段的内容user1带单位的词汇表

相关内容