编号、目录和标题树词汇表子条目

编号、目录和标题树词汇表子条目

我使用了一些词汇表,一个放在我文本的正文中,另一个放在我文档的后文中。我对前者应用了一种带有分层条目和子条目的自制风格(参见 MWE)。我会以不同的方式处理这两个词汇表,但我遇到了以下困难:

当我决定在软件包公告中设置配置时,我不知道该如何更改。我想要\usepackage[numberedsection=autolabel]{glossaries}第一个词汇表,\usepackage[section,numberedsection=nameref]{glossaries}另一个。

其次,我想为分层子条目(如章节、小节或小小节)编号,并使其出现在目录和标题中。但是,如果我尝试使用不带星号的章节来创建自己的词汇表样式,则无法进行编译。

% !TEX encoding = UTF-8 Unicode 
% !TEX TS-program = arara
\documentclass{scrbook} 
\usepackage[xindy={language=french, codepage=utf8}]{glossaries}
\newglossary*{his}{History}
\newglossary*{est}{Esthetic}
\makeglossaries

\newglossarystyle{arbre}{%
\renewenvironment{theglossary}{\tablehead{}\begin{description}}{\end{description}\tabletail{}}%
\renewcommand{\glossaryheader}{}%
\renewcommand*{\glsgroupskip}{}%
\renewcommand*{\glossentry}[2]{\section*{\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}}}% I want unscarred this \section
\renewcommand{\subglossentry}[3]{%
\ifnum##1=1\relax\subsection*{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=2\relax\subsubsection*{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=3\relax\item[\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}] \space\glossentrydesc{##2}\glspostdescription\space ##3\fi}}

\newglossaryentry{section}{type=est,name=section,description={\nopostdesc}}
\newglossaryentry{subsection}{type=est,name=subsection,parent=section,description={\nopostdesc}}
\newglossaryentry{subsubsection}{type=est,name=subsubsection,parent=subsection,description={\nopostdesc}}
\newglossaryentry{glouglou}{type=est,name=glouglou,parent=subsubsection,description={dindon}}
\newglossaryentry{coincoin}{type=his,name=coincoin,description={canard}}

\newcommand\est[5]{
\newglossaryentry{#1}{type=est,name=#1,description={\nopostdesc}}% 
\newglossaryentry{#2}{type=est,name=#2,parent=#1,description={\nopostdesc}}%
\newglossaryentry{#3}{type=est,name=#3,parent=#2,description={\nopostdesc}}% 
\newglossaryentry{#4}{type=est,name=#4,parent=#3,description={#5}}%
\gls{#4}, #5}%

\begin{document}
\est{section}{subsection}{subsubsection}{coco}{ara}, \gls{coincoin}, \gls{glouglou}.
\printglossary[type=est,style=arbre] 
% and now usepackage[section,numberedsection=nameref]{glossaries}
\printglossary[type=his]
\end{document}
% arara: xelatex
% arara: makeglossaries
% arara: xelatex

谢谢你的帮助。(这个问题是具有更多层次类别的词汇表

答案1

您可以使用\setupglossaries修改一些(但不是所有的) 中可在包选项中使用的设置。幸运的是,您想要调整的设置可能会在文档中更改。首先使用

\setupglossaries{numberedsection=autolabel}

然后

\setupglossaries{section,numberedsection=nameref}

修改后的 MWE:

\documentclass{scrbook} 
\usepackage[xindy={language=french, codepage=utf8}]{glossaries}
\newglossary*{his}{History}
\newglossary*{est}{Esthetic}
\makeglossaries

\newglossarystyle{arbre}{%
\renewenvironment{theglossary}{\tablehead{}\begin{description}}{\end{description}\tabletail{}}%
\renewcommand{\glossaryheader}{}%
\renewcommand*{\glsgroupskip}{}%
\renewcommand*{\glossentry}[2]{\section*{\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}}}% I want unscarred this \section
\renewcommand{\subglossentry}[3]{%
\ifnum##1=1\relax\subsection*{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=2\relax\subsubsection*{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=3\relax\item[\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}] \space\glossentrydesc{##2}\glspostdescription\space ##3\fi}}

\newglossaryentry{section}{type=est,name=section,description={\nopostdesc}}
\newglossaryentry{subsection}{type=est,name=subsection,parent=section,description={\nopostdesc}}
\newglossaryentry{subsubsection}{type=est,name=subsubsection,parent=subsection,description={\nopostdesc}}
\newglossaryentry{glouglou}{type=est,name=glouglou,parent=subsubsection,description={dindon}}
\newglossaryentry{coincoin}{type=his,name=coincoin,description={canard}}

\newcommand\est[5]{
\newglossaryentry{#1}{type=est,name=#1,description={\nopostdesc}}% 
\newglossaryentry{#2}{type=est,name=#2,parent=#1,description={\nopostdesc}}%
\newglossaryentry{#3}{type=est,name=#3,parent=#2,description={\nopostdesc}}% 
\newglossaryentry{#4}{type=est,name=#4,parent=#3,description={#5}}%
\gls{#4}, #5}%

\begin{document}
\setupglossaries{numberedsection=autolabel}
\est{section}{subsection}{subsubsection}{coco}{ara}, \gls{coincoin}, \gls{glouglou}.
\printglossary[type=est,style=arbre] 
\setupglossaries{section,numberedsection=nameref}
\printglossary[type=his]
\end{document}

编辑:对于词汇表样式中的编号部分,您需要使用可选参数来\section克服扩展问题和其他不需要的内容进入.toc文件:

\renewcommand*{\glossentry}[2]{\section[\glsentryname{##1}]{\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}}}
\renewcommand{\subglossentry}[3]{%
\ifnum##1=1\relax\subsection[\glsentryname{##2}]{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=2\relax\subsubsection[\glsentryname{##2}]{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=3\relax\item[\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}] \space\glossentrydesc{##2}\glspostdescription\space ##3\fi}

相关内容