如何排版一个新的词汇表条目?

如何排版一个新的词汇表条目?

继续

https://tex.stackexchange.com/questions/241636/how-to-typeset-a-cross-referenced-encylopedia

我想向 a 添加额外字段\newglossaryentry并根据自己的规则进行排版。额外字段例如是单词的类型,就像vt英语词典中的及物动词一样。

在 \newcommand 中的 \newglossaryentry 中添加符号字段

似乎没有回答这个问题。字段集是固定的吗?如果我想添加更多字段怎么办?

更新:

例子:

在此处输入图片描述

这里,

  • vt 是语法类型
  • 加载是定义
  • 给电池充电就是一个用法的例子,它可以是多种

答案1

对于您描述的格式,我的解决方案是添加两个新键,并基于现有列表模板样式创建新的自定义样式。

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage{siunitx,microtype,textcomp,textgreek}
\usepackage[nogroupskip,toc,indexonlyfirst]{glossaries}

%=============================================================================
%   G L O S S A R Y   S E T U P
%=============================================================================

\glsaddkey
{gramType}          % new key
{\relax}        % default value if "unit" isn't used in \newglossaryentry
{\glsentrygramType} % analogous to \glsentrytext
{\GlsentrygramType} % analogous to \Glsentrytext
{\glsgramType}      % analogous to \glstext
{\GlsgramType}      % analogous to \Glstext
{\GLSgramType}      % analogous to \GLStext

\glsaddkey
{example}     % new key
{\relax}            % default value if "dimension" isn't used in \newglossaryentry
{\glsentryexample}      % analogous to \glsentrytext
{\Glsentryexample}      % analogous to \Glsentrytext
{\glsexample}           % analogous to \glstext
{\Glsexample}           % analogous to \Glstext
{\GLSexample}           % analogous to \GLStext

\newglossary[alg]{acronym}{acr}{acn}{List of Acronyms}% if not using the acronyms package option - can declare it myself
\newglossary[dnlg]{enc}{dnt}{dntn}{Cross-Referenced Encyclopaedia}

% please note these should be accompanied by command line calls to makeindex eg (for windows):

% "%MikTexPath%makeindex.exe" -s "main.ist" -t "main.glg"  -o "main.gls"  "main.glo"
% "%MikTexPath%makeindex.exe" -s "main.ist" -t "main.alg"  -o "main.acr"  "main.acn"
% "%MikTexPath%makeindex.exe" -s "main.ist" -t "main.dnlg" -o "main.dnt"  "main.dntn"

%==================================================================================================================================================================

\newglossarystyle{custom_encentry}{%
    \setglossarystyle{list}% base this style on the list style
    \renewcommand*{\glossentry}[2]{%
        \item[\glsentryitem{##1}%
        \glstarget{##1}{\glossentryname{##1}}]
        \textit{\glsentrygramType{##1}}\space : \space \glossentrydesc{##1},\space \glsentryexample{##1} \glspostdescription\space }%
}

%==================================================================================================================================================================



\newglossaryentry{vt}{ type={acronym}, sort={vt},  name={vt}, short={vt}, first={vt}, description={transitive verb} }


\newglossaryentry{charge}{ type={enc}, name={charge}, description={to load is the definition}, example={charge a battery}, gramType={\gls{vt}} }


\makeglossaries
\begin{document}
    \noindent
    Begin document:

     In-text use of the word \gls{charge}

    \printglossary[type=acronym]
    \printglossary[type=enc,style=custom_encentry]

\end{document}

相关内容