2

I have a particular generic function in my document whose signature is $\mathscr{T}_{i}(\cdot)$. This function is used with different arguments in the text, e.g., $\mathscr{T}_{i}(\Lambda_j)$, $\mathscr{T}_{i}(\Lambda_j)$, etc. Using the glassories package and \gls command, every symbol appearing in the list of symbols is exactly identical to a symbol in the text. However, what I need is the substitution of the function-with-argument with the generic signature of the function in the list of symbols. Here is an MWE:

main.tex:

\documentclass{article}

\usepackage[nogroupskip]{glossaries}

\makenoidxglossaries
\loadglsentries{gloss-symb}

\newglossarystyle{mylong}{%
    \setglossarystyle{long}%
    \renewenvironment{theglossary}%
    {\begin{longtable}[l]{@{}p{\dimexpr 2cm-\tabcolsep}p{0.8\hsize}}}
        {\end{longtable}}%
}

\begin{document}

\printnoidxglossary[sort=def,style=mylong,title={List of Symbols}]
\printnoidxglossary[type=symbols,sort=use]

\input{myChap}

\end{document}

myChap.tex:

Here is the function \gls{myFunction}

Here is the function $\mathsf{T}_{i}(\Lambda_j)$

gloss-symb:

\newglossaryentry{myFunction}{name={\ensuremath{\mathsf{T}_{i}(\Omega_j)}},description={The intended function}}

The output would be:

enter image description here

How can I end up with this?:

enter image description here

1 Answers1

1

This seems to work:

\documentclass{article}

\usepackage[nogroupskip]{glossaries}

\makenoidxglossaries

%%% this can go in the gloss-symb file
\protected\def\myFunctionArg{{\cdot}}
\newglossaryentry{myFunction}{
  name={\ensuremath{\mathsf{T}_{i}(\myFunctionArg})},
  description={The intended function},
}
%%% (gloss-symb end)

\newglossarystyle{mylong}{%
    \setglossarystyle{long}%
    \renewenvironment{theglossary}%
    {\begin{longtable}[l]{@{}p{\dimexpr 2cm-\tabcolsep}p{0.8\hsize}}}
        {\end{longtable}}%
}
\makeatletter
\newcommand{\vargls}[2]{%
  \begingroup
  \@namedef{#1Arg}{#2}%
  \gls{#1}%
  \endgroup
}
\makeatother

\begin{document}

\printnoidxglossary[sort=def,style=mylong,title={List of Symbols}]

\clearpage

% page 2
Here is the function \vargls{myFunction}{\Omega_j}

\clearpage

% page 3
Here is the function $\vargls{myFunction}{\Lambda_j}$

\end{document}

The variable part is stored in \myFunctionArg (taking the label as model and adding Arg). With \vargls we can set the auxiliary macro to whatever we want. Doing it in a group ensures that the initial definition (which needs to be \protected) is used for the glossary.

Page 1 (the list of symbols)

enter image description here

Page 2 (the first callout)

enter image description here

Page 3 (the second callout)

enter image description here

egreg
  • 1,121,712