我正在编写一个使用 的包skdoc
,它用于glossaries
自动创建索引列出命令、环境等。
现在,我想手动(简单地)向索引中添加一些关键字,就像\index
在 中所做的那样makeidx
。
glossaries
是否有类似这样的功能skdoc
?
\documentclass{skdoc}
\SelfPreambleTo{\mypreamble}
\DeclareFile[key=package,preamble=\mypreamble]{test.sty}
\OnlyDescription
\begin{document}
\package{test}
\author{Homer Simpson}
\email{[email protected]}
\maketitle
\begin{abstract}
The \thepackage\ package provides some stuff.
\end{abstract}
\section{Documentation}
% !!! HERE I WANT TO INDEX A KEYWORT !!!
Explain some stuff about keyword\index{keyword}.
\DescribeMacro\yeah
Describe macro here.
\Implementation
\section{Implementation}
\begin{MacroCode}{package}
\ProvidesExplPackage{test}
{2017/05/03}{1.0}{Some things about donuts}
\end{MacroCode}
\begin{macro}{\yeah}
\begin{MacroCode}{package}
\RenewDocumentCommand\yeah{ }{%
Yeah!
}
\end{MacroCode}
\end{macro}
\begin{MacroCode}{package}
\endinput
\end{MacroCode}
\Finale
\PrintChanges
\PrintIndex
\end{document}
答案1
该类skdoc
生成一个名为的词汇表index
,因此您可以使用glossaries
命令来实现您想要的功能。
也就是说,要添加keyword
到索引,您可以在序言中声明:
\newglossaryentry{keyword}{type=index,name={keyword},description=\nopostdesc}
并在需要时使用\gls{keyword}
,而不是简单地书写。keyword
梅威瑟:
\documentclass{skdoc}
\newglossaryentry{keyword}{type=index,name={keyword},description=\nopostdesc}
\SelfPreambleTo{\mypreamble}
\DeclareFile[key=package,preamble=\mypreamble]{test.sty}
\OnlyDescription
\begin{document}
\package{test}
\author{Homer Simpson}
\email{[email protected]}
\maketitle
\begin{abstract}
The \thepackage\ package provides some stuff.
\end{abstract}
\section{Documentation}
% !!! HERE I WANT TO INDEX A KEYWORT !!!
Explain some stuff about \gls{keyword}.
\DescribeMacro\yeah
Describe macro here.
\Implementation
\section{Implementation}
\begin{MacroCode}{package}
\ProvidesExplPackage{test}
{2017/05/03}{1.0}{Some things about donuts}
\end{MacroCode}
\begin{macro}{\yeah}
\begin{MacroCode}{package}
\RenewDocumentCommand\yeah{ }{%
Yeah!
}
\end{MacroCode}
\end{macro}
\begin{MacroCode}{package}
\endinput
\end{MacroCode}
\Finale
\PrintChanges
\PrintIndex
\end{document}
输出:
或者,您可以定义一个新命令\myindex
\newcommand{\myindex}[1]{%
\newglossaryentry{#1}{type=index,name={#1},description=\nopostdesc}%
\glsadd{#1}}
就像 一样 使用\index
。
梅威瑟:
\documentclass{skdoc}
\newcommand{\myindex}[1]{%
\newglossaryentry{#1}{type=index,name={#1},description=\nopostdesc}%
\glsadd{#1}}
\SelfPreambleTo{\mypreamble}
\DeclareFile[key=package,preamble=\mypreamble]{test.sty}
\OnlyDescription
\begin{document}
\package{test}
\author{Homer Simpson}
\email{[email protected]}
\maketitle
\begin{abstract}
The \thepackage\ package provides some stuff.
\end{abstract}
\section{Documentation}
% !!! HERE I WANT TO INDEX A KEYWORT !!!
Explain some stuff about keyword\myindex{keyword}.
\DescribeMacro\yeah
Describe macro here.
\Implementation
\section{Implementation}
\begin{MacroCode}{package}
\ProvidesExplPackage{test}
{2017/05/03}{1.0}{Some things about donuts}
\end{MacroCode}
\begin{macro}{\yeah}
\begin{MacroCode}{package}
\RenewDocumentCommand\yeah{ }{%
Yeah!
}
\end{MacroCode}
\end{macro}
\begin{MacroCode}{package}
\endinput
\end{MacroCode}
\Finale
\PrintChanges
\PrintIndex
\end{document}
输出与上面相同。