词汇表

词汇表

假设您希望\sup在词汇表中引用某个特定数学运算符(例如 supremum )的所有出现。怎么做?好吧,我会尝试先按\let\sup\relax,然后按\DeclareMathOperator{\sup}{\gls{...}}。但是,这种方法会在“sup”前面产生不必要的水平空间。如何默认消除它并仍然保留超链接?下面,我将标准方法\sup与我的方法进行比较。

代码:

\documentclass{svmono}%%% Obtainable from https://www.springer.com/gp/authors-editors/book-authors-editors/manuscript-preparation/5636
\usepackage{mathtools}%%% loads amsmath internally
\mathtoolsset{mathic=true} %%% See https://tex.stackexchange.com/a/3496/
\usepackage[hidelinks]{hyperref}
%%% The next hack improves how hyperref jives with svindd.ist, see https://tex.stackexchange.com/a/429446
\makeatletter
\def\@commahyperpage#1{\@@commahyperpage#1,\,,\\}
\def\@@commahyperpage#1,\,#2,#3\\{%
  \ifx\\#2\\%
    \HyInd@pagelink{#1}%
  \else
    \HyInd@pagelink{#1},\,\HyInd@pagelink{#2}%
  \fi
}
\makeatother
\usepackage[makeindex,toc,nogroupskip,nomain]{glossaries-extra}
\setglossarystyle{long3col}\renewcommand{\glspagelistwidth}{10em}
\GlsSetQuote{+} %%% Hack to work with makeindex
\newglossary[nlg]{notation}{not}{ntn}{Notation}
\makeglossaries
\glssetcategoryattribute{mathoperator}{hyperoutside}{false}
\glssetcategoryattribute{mathoperator}{textformat}{mathop}
\newglossaryentry{not:supremum}{type=notation, name={\(\mathrm{sup}\)}, category=mathoperator, text={\mathop{\mathrm{sup}}}, sort={supremum}, description={The supremum of a set is the smallest upper bound for the set.}}
\DeclareMathOperator{\mysup}{\gls{not:supremum}}
\begin{document}
\begin{align*}
  f(\sup S) &= \sup f(S)\\
  f(\mysup S) &= \mysup f(S)
\end{align*}
\printglossaries
\end{document}

输出,第 1 页:

pdflatex 生成的结果第 1 页

输出,第 3 页:

pdflatex 生成结果的第 3 页

如您所见,“(”和“sup”之间有一些不需要的空格,并且“=”和“sup”之间也有一些空格。

(题外话:我对这个问题的大小表示歉意;之前对这个问题的较小修改似乎有一个技术上正确但无用的答案。)

答案1

我认为对每个对象的出现都进行索引并不是一个好主意。

无论如何,问题在于一个普通原子被插入到不合适的位置,你可以用\!

\documentclass{article}
\usepackage{mathtools}%%% loads amsmath internally
\mathtoolsset{mathic=true} %%% See https://tex.stackexchange.com/a/3496/
\usepackage[hidelinks]{hyperref}
%%% The next hack improves how hyperref jives with svindd.ist, see https://tex.stackexchange.com/a/429446
\makeatletter
\def\@commahyperpage#1{\@@commahyperpage#1,\,,\\}
\def\@@commahyperpage#1,\,#2,#3\\{%
  \ifx\\#2\\%
    \HyInd@pagelink{#1}%
  \else
    \HyInd@pagelink{#1},\,\HyInd@pagelink{#2}%
  \fi
}
\makeatother
\usepackage[makeindex,toc,nogroupskip,nomain]{glossaries-extra}

\setglossarystyle{long3col}\renewcommand{\glspagelistwidth}{10em}

\GlsSetQuote{+} %%% Hack to work with makeindex
\newglossary[nlg]{notation}{not}{ntn}{Notation}
\makeglossaries

\glssetcategoryattribute{mathoperator}{hyperoutside}{false}
\glssetcategoryattribute{mathoperator}{textformat}{mathop}

\let\supop\sup \let\sup\relax
\DeclareMathOperator*{\sup}{\gls{not:supremum}}

\newglossaryentry{not:supremum}{
  type=notation,
  name={\(\supop\)},
  category=mathoperator,
  text=\!\supop,
  sort={supremum},
  description={The supremum of a set is the smallest upper bound for the set.}
}


\begin{document}
\begin{align*}
  f(\supop S) &= \supop f(S)\\
  f(\sup S) &= \sup f(S) \\
  \max\sup\max &= \max\supop\max
\end{align*}

\printglossaries

\end{document}

在此处输入图片描述

相关内容