包括带有说明和页码的符号列表

包括带有说明和页码的符号列表

我想在后面的内容中列出一个按首次出现顺序排列的列表:

数学符号 - 点填充 - 简短描述 - 页码

例如

在此处输入图片描述

这是一个可以工作但却产生错误结果的最小示例:

\documentclass{book}

\usepackage{tocloft}

\newcommand{\listexamplename}{} 

\newlistof{mathsymbols}{msy}{\listexamplename}

\newcommand{\msy}[1]{%

\addcontentsline{msy}{mathsymbols}{#1}}

\begin{document}

$a\in b$ while $c=d$. 

\msy{$\in$ (membership)}

\msy{$=$ (equality)}

\listofmathsymbols 

\end{document}

答案1

这是一个解决方案(快速而粗糙)

编辑:用户指南我们需要\mtsymb[description]{alpha}首先使用来提供描述,这可以在任何地方进行,稍后我们使用它\mtsymb{alpha}来获取页码,但我们也可以输入\mtsymb[description]{alpha}

\mtsymb[description]{alpha}在序言中仅保存描述。在正文中保存描述(如果尚未保存),打印符号并保存页码。

\mtsymb{alpha}仅在正文中打印符号并保存页码。

我们需要:如果 hyperref 没有加载

\providecommand\hypertarget[2]{#2}
\providecommand\hyperlink[2]{#2}

创建并输入列表

\newwrite\mtmathsymb
\immediate\openout\mtmathsymb=\jobname.msy
\newcommand{\listsymbname}{List of symbols}

\makeatletter 
\newcommand{\listofmathsymbols}{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listsymbname
      \@mkboth{\MakeUppercase\listsymbname}{\MakeUppercase\listsymbname}}%
    \immediate\closeout\mtmathsymb%
    \input{\jobname.msy}
    \if@restonecol\twocolumn\fi
    }

列表中的条目样式。

\newcommand{\mtsymbolsty}[1]{%
\addpenalty{-\@highpenalty}
\begingroup
\parindent0pt\leavevmode
\hyperlink{mtmathlabel#1}{\ensuremath{\csname#1\endcsname}}%
\dotfill\hyperlink{mtmathlabel#1}{\csname mtsymdisc#1\endcsname}%
\hbox to \@pnumwidth{\hss\pageref{mtmathlabel#1}}\par%
\endgroup
\penalty\@highpenalty}

完整代码(稍后可能会编辑)

\documentclass{book}

\usepackage{hyperref}

\providecommand\hypertarget[2]{#2}
\providecommand\hyperlink[2]{#2}

\newwrite\mtmathsymb
\immediate\openout\mtmathsymb=\jobname.msy
\newcommand{\listsymbname}{List of symbols}

\makeatletter 
\newcommand{\listofmathsymbols}{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listsymbname
      \@mkboth{\MakeUppercase\listsymbname}{\MakeUppercase\listsymbname}}%
    \immediate\closeout\mtmathsymb%
    \input{\jobname.msy}
    \if@restonecol\twocolumn\fi
    }

\newcommand{\mtsymbolsty}[1]{%
\addpenalty{-\@highpenalty}
\begingroup
\parindent0pt\leavevmode
\hyperlink{mtmathlabel#1}{\ensuremath{\csname#1\endcsname}}%
\dotfill\hyperlink{mtmathlabel#1}{\csname mtsymdisc#1\endcsname}%
\hbox to \@pnumwidth{\hss\pageref{mtmathlabel#1}}\par%
\endgroup
\penalty\@highpenalty}

\newcommand{\Mtsymbolsty}[1]{%
\addpenalty{-\@highpenalty}
\begingroup
\parindent0pt\leavevmode
\hyperlink{mtmathlabel#1}{\ensuremath{#1}}%
\dotfill\hyperlink{mtmathlabel#1}{\csname mtsymdisc#1\endcsname}%
\hbox to \@pnumwidth{\hss\pageref{mtmathlabel#1}}\par%
\endgroup
\penalty\@highpenalty}

\newcommand{\mtsymb}[2][]{%
\@ifundefined{mtsymdisc#2}{%  check if symbol already described
\@namedef{mtsymdisc#2}{#1}}{}%
\expandafter\ifx\csname mtsymdisc#2\endcsname\empty\errmessage{no description}\fi%
\ifx\document\@notprerr%   check if preambl--body
\@ifundefined{mtmathsym#2}{%   check first occurrence
\@namedef{mtmathsym#2}{mt}%
\label{mtmathlabel#2}\hypertarget{mtmathlabel#2}{\ensuremath{\csname#2\endcsname}}%
\immediate\write\mtmathsymb{\string\mtsymbolsty{#2}}}{\ensuremath{\csname#2\endcsname}}%
\fi}

\newcommand{\Mtsymb}[2][]{%
\@ifundefined{mtsymdisc#2}{%  check if symbol already described
\@namedef{mtsymdisc#2}{#1}}{}%
\expandafter\ifx\csname mtsymdisc#2\endcsname\empty\errmessage{no description}\fi%
\ifx\document\@notprerr%   check if preambl--body
\@ifundefined{mtmathsym#2}{%   check first occurrence
\@namedef{mtmathsym#2}{mt}%
\label{mtmathlabel#2}\hypertarget{mtmathlabel#2}{\ensuremath{#2}}%
\immediate\write\mtmathsymb{\string\Mtsymbolsty{#2}}}{\ensuremath{#2}}%
\fi}
\makeatother

\mtsymb[description]{alpha} % this only describe symbol (in preambl)
\mtsymb[description beta]{beta}
\mtsymb[description zeta]{zeta}
\Mtsymb[equality]{=}


\begin{document}
\tableofcontents
\chapter{Foo}
test bla bla \mtsymb{alpha}  %  first occurrence use(output) the symbol and add entry to list
and test bla bla \mtsymb{beta}
and test bla bla \mtsymb[description gamma]{gamma} %this uses, describes and add entry 
bla bla  \Mtsymb{=}
\chapter{Bar $\gamma$}

bla bla \mtsymb{gamma} %this only use(output) symbol

and test bla bla  \mtsymb[second description beta]{beta} %this only use symbol

and test bla bla \mtsymb{alpha}

and test bla bla \mtsymb{zeta}

\listofmathsymbols 
\end{document}

笔记我们使用命令\mtsymb{alpha},对于像... \mtsymb[description]{alpha}这样的符号,以及,对于像=,<...这样的符号,可能启动版本更好。\alpha\Mtsymb{=}\Mtsymb[description]{<}

局限性我们不能\mtsymb在类似命令的部分中使用命令。

相关内容