我正在尝试将词汇表包含在 Latex 中的枚举列表中。通常,词汇表似乎仅作为章节或节包含在内。我需要将其移动到枚举列表中。以下是一个最小示例:
\documentclass[11pt]{article}
\usepackage[nonumberlist]{glossaries}
\setglossarypreamble{Glossaries to follow here-}
\makeglossaries
\newglossaryentry{cbr}{name = {Central Board}, description = {refers
to the Central Board of the central government}}
\newglossaryentry{cg}{name = {Central Government}, description =
{refers to the Government of India}}
\begin{document}
\section{The present output}
Need to use the words in a system: \gls{cbr} and \gls{cg}
\begin{enumerate}
\item \printglossaries
\end{enumerate}
\section{The required output}
Need to use the words in a system: \gls{cbr} and \gls{cg}
\begin{enumerate}
\item Glossaries follow here--
\begin{enumerate}
\item Central Board refers to the Central Board of the government;
\item Central Government refers to the Government of India
\end{enumerate}
\end{enumerate}
\end{document}
答案1
每个词汇表都以
\glossarysection[\glossarytoctitle]{\glossarytitle}
默认情况下,根据文档类\glossarysection
,执行\section*
或\chapter*
,因此您需要重新定义\glossarysection
。例如:
\begin{enumerate}
\renewcommand{\glossarysection}[2][]{\item}%
\printglossaries
\end{enumerate}
您还需要定义一个使用enumerate
环境的词汇表样式。最简单的方法可能是定义一个适应该list
样式的样式:
\newglossarystyle{enum}{%
\setglossarystyle{list}%
\renewenvironment{theglossary}%
{\begin{enumerate}}{\end{enumerate}}%
\renewcommand*{\glossentry}[2]{%
\item\glsentryitem{##1}%
\glstarget{##1}{\glossentryname{##1}}
\glossentrydesc{##1}\glspostdescription\space ##2}%
}
\setglossarystyle{enum}
完整示例如下:
\documentclass[11pt]{article}
\usepackage[nonumberlist]{glossaries}
\setglossarypreamble{Glossaries to follow here-}
\makeglossaries
\newglossaryentry{cbr}{name = {Central Board}, description =
{refers
to the Central Board of the central government}}
\newglossaryentry{cg}{name = {Central Government}, description =
{refers to the Government of India}}
\newglossarystyle{enum}{%
\setglossarystyle{list}%
\renewenvironment{theglossary}%
{\begin{enumerate}}{\end{enumerate}}%
\renewcommand*{\glossentry}[2]{%
\item\glsentryitem{##1}%
\glstarget{##1}{\glossentryname{##1}}
\glossentrydesc{##1}\glspostdescription\space ##2}%
}
\setglossarystyle{enum}
\begin{document}
\section{The present output}
Need to use the words in a system: \gls{cbr} and \gls{cg}
\begin{enumerate}
\renewcommand{\glossarysection}[2][]{\item}%
\printglossaries
\end{enumerate}
\section{The required output}
Need to use the words in a system: \gls{cbr} and \gls{cg}
\begin{enumerate}
\item Glossaries follow here--
\begin{enumerate}
\item Central Board refers to the Central Board of the government;
\item Central Government refers to the Government of India
\end{enumerate}
\end{enumerate}
\end{document}
得出的结果为: