是否有一种简单的方法可以将所有词汇表合并到一个索引中?

是否有一种简单的方法可以将所有词汇表合并到一个索引中?

我习惯glossaries制作多个首字母缩略词和符号列表,并将它们打印在主文档之前。然后我想将它们全部打印在主文档之后的索引中,不带标题type并一起排序。

例子:


**符号*

C光速

H普朗克常数

缩略词

第一人称射击游戏 每秒帧数

主要文件

指数

每秒帧数 (FPS) ............ p.1

普朗克常数(H)....第2页

光速 (C)..................................第3页


我的当前梅威瑟:

\documentclass{report}
\usepackage{siunitx}
\usepackage[nomain, acronyms, nonumberlist, section=section]{glossaries}
\usepackage{glossary-mcols}
\usepackage{xparse}

\setlength{\glsdescwidth}{15cm}

\newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create add symbolslist


\glsaddkey{symbolvalue}{\glsentrytext{\glslabel}}{\glsentrysymbolvalue} {\GLsentrysymbolvalue}{\glssymbolvalue}{\Glssymbolvalue}{\GLSsymbolvalue}
\glssetnoexpandfield{symbolvalue}

\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}
\glssetnoexpandfield{unit}

\makeglossaries                                   % activate glossaries-package

\NewDocumentCommand{\newglossaryconstant}{o m m m m m}{\newglossaryentry{#2}{%
    name=\ensuremath{#3},
    description={#4},
    symbolvalue={#5},
    unit={#6},
    first={#4, (\ensuremath{#3})},
    text={\ensuremath{#3}},
    type=symbolslist,
    sort=\IfNoValueTF{#1}{#3}{#1}}}


\newglossaryconstant{lightspeed}{c}{speed of light}{299792432}{\si{\meter/\second}}

\newglossaryconstant[h]{planck}{h}{Planck's constant}{$6.6261\cdot10^{-34}$}{[\si{\joule\second}]}

\newacronym[longplural={Frames per Second}]{fps}{FPS}{Frame per Second}

\newglossarystyle{mylist}{%
% put the glossary in the itemize environment:
\renewenvironment{theglossary}{\setlength{\LTleft}{0pt}\begin{longtable}{l>{\raggedright}p{.4\textwidth}>{\raggedleft}p{0.3\textwidth}r}}{\end{longtable}}%
% have nothing after \begin{theglossary}:
\renewcommand*{\glossaryheader}{%  Change the table header
   Sign &  Description & Value & Unit \\
  \endhead}
% have nothing between glossary groups:
\renewcommand*{\glsgroupheading}[1]{\vspace{-.5em}\\ \textbf{\glsgetgrouptitle{##1}}\\}%
\renewcommand*{\glsgroupskip}{}%
% set how each entry should appear:
\renewcommand*{\glossentry}[2]{%  Change the displayed items
  \glstarget{##1}{\glossentryname{##1}} %
  & \glossentrydesc{##1}% Description
  & \glssymbolvalue{##1}
  & \glsunit{##1}%
  \tabularnewline
}
}

\newglossarystyle{myindex}{%
\glossarystyle{mcolindexgroup}
\renewcommand*{\glsgroupheading}[1]{}%
}


\begin{document}

\glsaddall
\printglossary[type=symbolslist,style=mylist]   % list of symbols
\printglossary[type=\acronymtype] % prints just the list of acronyms

\glsresetall
\section{first}

\Gls{planck}

\subsection{second}
\Gls{planck}

\renewcommand{\glsmcols}{3}
\setglossarystyle{myindex}

\printglossaries
\end{document}

给了我这个结果:

在此处输入图片描述

答案1

您可以使用makeindex将所有条目合并到一个文件中。如果删除该nomain选项,您可以main在最后使用词汇表作为合并索引,并makeindex创建一个合并文件。

修改后的 MWE:

\documentclass{report}
\usepackage{siunitx}
\usepackage[acronyms, nonumberlist, section=section]{glossaries}% removed `nomain'
\usepackage{glossary-mcols}
\usepackage{xparse}

\setlength{\glsdescwidth}{15cm}

\newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create add symbolslist


\glsaddkey{symbolvalue}{\glsentrytext{\glslabel}}{\glsentrysymbolvalue} {\GLsentrysymbolvalue}{\glssymbolvalue}{\Glssymbolvalue}{\GLSsymbolvalue}
\glssetnoexpandfield{symbolvalue}

\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}
\glssetnoexpandfield{unit}

\makeglossaries                                   % activate glossaries-package

\NewDocumentCommand{\newglossaryconstant}{o m m m m m}{\newglossaryentry{#2}{%
    name=\ensuremath{#3},
    description={#4},
    symbolvalue={#5},
    unit={#6},
    first={#4, (\ensuremath{#3})},
    text={\ensuremath{#3}},
    type=symbolslist,
    sort=\IfNoValueTF{#1}{#3}{#1}}}


\newglossaryconstant{lightspeed}{c}{speed of light}{299792432}{\si{\meter/\second}}

\newglossaryconstant[h]{planck}{h}{Planck's constant}{$6.6261\cdot10^{-34}$}{[\si{\joule\second}]}

\newacronym[longplural={Frames per Second}]{fps}{FPS}{Frame per Second}

\newglossarystyle{mylist}{%
% put the glossary in the itemize environment:
\renewenvironment{theglossary}{\setlength{\LTleft}{0pt}\begin{longtable}{l>{\raggedright}p{.4\textwidth}>{\raggedleft}p{0.3\textwidth}r}}{\end{longtable}}%
% have nothing after \begin{theglossary}:
\renewcommand*{\glossaryheader}{%  Change the table header
   Sign &  Description & Value & Unit \\
  \endhead}
% have nothing between glossary groups:
\renewcommand*{\glsgroupheading}[1]{\vspace{-.5em}\\ \textbf{\glsgetgrouptitle{##1}}\\}%
\renewcommand*{\glsgroupskip}{}%
% set how each entry should appear:
\renewcommand*{\glossentry}[2]{%  Change the displayed items
  \glstarget{##1}{\glossentryname{##1}} %
  & \glossentrydesc{##1}% Description
  & \glssymbolvalue{##1}
  & \glsunit{##1}%
  \tabularnewline
}
}

\newglossarystyle{myindex}{%
\setglossarystyle{mcolindexgroup}% changed \glossarystyle to \setglossarystyle
\renewcommand*{\glsgroupheading}[1]{}%
}


\begin{document}

\glsaddall
\printglossary[type=symbolslist,style=mylist]   % list of symbols
\printglossary[type=\acronymtype] % prints just the list of acronyms

\glsresetall
\section{first}

\Gls{planck}

\subsection{second}
\Gls{planck}

\renewcommand{\glsmcols}{3}
\setglossarystyle{myindex}

\printglossary[title=Index]% main glossary
\end{document}

(注:\glossarystyle已弃用。我已将其替换为\setglossarystyle。如果无法识别此新命令,那么我建议您更新您的版本glossaries。顺便说一句,您可以直接使用mcolindex,其功能与您的myindex风格相同。)

如果该文件名为test.tex,则构建过程为:

pdflatex test
makeindex -s test.ist -t test.slg -o test.syi test.syg
makeindex -s test.ist -t test.alg -o test.acr test.acn
makeindex -s test.ist -t test.glg -o test.gls test.acn test.syg
pdflatex test

第三次makeindex调用合并test.acn(首字母缩略词)和test.syg(符号),并将结果保存到test.gls(主要)。

文件图像

相关内容