3

How can I forced the Symbol to be printed in capitalized form or full uppercase in the glossary print only (with non capitalized form declared in the field symbol)?

The best solution for me would be to have like a new field symbolname when declaring a new glossary entry, this field will be used by LaTeX for printing the symbol in the glossary print only. The symbol declared in the field symbol will be used in the document text only. In other words, I would like to have - for symbol field -, the same result given when I use the name field and the text field, which permits to dissociate the use in glossary print from the use in text...

Here a MWE,

\documentclass{article}
\usepackage[style=tree]{glossaries-extra}

\makenoidxglossaries

\newglossaryentry{subsytem}{name={Subssytems},description={\glspar},sort={4}} \newglossaryentry{compressor} { name={Compressor}, text={compressor}, sort={compressor}, description={Air Compressor}, symbol={cp}, parent=subsytem } \newglossaryentry{compressor_motor} { name={Compressor Motor}, sort={compressor motor}, text={compressor motor}, description={Motor of the \Gls{compressor}}, symbol={cm}, parent=subsytem }

\begin{document} \gls{compressor_motor} \gls{compressor} \printnoidxglossary \end{document}

Instead of this result :

enter image description here

I would like something like that ("Compressor (Cp)" instead of "Compressor (cp)" and "Compressor Motor (CM)" instead of "Compressor Motor (cm)") :

enter image description here

But again, I would like the symbol to be declared in lowercase in the symbol field (cp or cm) as shown in the non-working exemple below :

\newglossaryentry{subsytem}{name={Subssytems},description={\glspar},sort={4}}
\newglossaryentry{compressor}
{
  name={Compressor},
  text={compressor},
  sort={compressor},
  description={Air Compressor},
  symbolname={Cp},%!!!!!!!!!!!!!!!!!!!!!!!!!
  symbol={cp},
  parent=subsytem
}
\newglossaryentry{compressor_motor}
{
  name={Compressor Motor},
  sort={compressor motor},
  text={compressor motor},
  description={Motor of the \Gls{compressor}},
  symbolname={CM},%!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  symbol={cm},
  parent=subsytem
}
\begin{document}
\gls{compressor_motor}
\gls{compressor}
\printnoidxglossary
\end{document}

Why I want lowercase in symbol field?

Because I use the lowercase symbol form to declare other "math entries" like below the use of \glssymbol{compressor} in the name field:

\usepackage{amsmath,bm,times}
\newglossaryentry{PQ}{name={Physical Quantities},description={\glspar},sort={5}}
\newglossaryentry{Qcp}
{
  name={$\mathbf{\bm{Q}}_{\glssymbol{compressor},out}$},
  sort={Qcpout},
  text={\Glssymbol{compressor} Air Outlet Mass Flow Rate},
  description={Compressor Air Outlet Mass Flow Rate},
  parent=PQ
}

With these "math entries" I want the symbol \glssymbol{compressor} in lowercase. But when I use the symbol in the text document, sometimes I will use the \GLSsymbol form or \Glssymbol or \glssymbol. But currently in my MWE the symbol is printed in lowercase in the glossary (off course) but I would prefer a Capitalized or uppercase form and it depends on me (it's a case by case choice). This is why I would prefer a solution with a new field (like symbolname) in order to manually choose if I want to print the symbol in capitalisez form (Cp) or uppercase form (CM)...

zetyty
  • 779

1 Answers1

4

UPDATE (2) after follow-up question.

There is now a new key-defined symbol name (symbolname) that will be used to print the glossary. You can use any other "symbol" you want, not just uppercase, as shown in this example.

If symbolname is not defined it will be use the symbol value to print the glossary. (new) <<

A new entry compressor_valve was added to show this default behavior.

d

\documentclass{article}
\usepackage[style=tree]{glossaries-extra}

\usepackage{xcolor} \usepackage{tikz}

%*************************************** added <<<<<<<<<<<<<<<<<< \glsaddkey*% {symbolname}% key {\glsentrysymbol{\glslabel}}% default value CHANGED <<<<<<<<<<<<<<<<<< {\glsentrysymbolname}% command analogous to \glsentrytext {\Glsentrysymbolname}% command analogous to \Glsentrytext {\glssymbolname}% command analogous to \glstext {\Glssymbolname}% command analogous to \Glstext {\GLSsymbolname}% command analogous to \GLStext

\renewcommand{\subglossentry}[3]{% <<<<<<<<<<<<<<<< \hangindent#1\glstreeindent\relax \parindent#1\glstreeindent\relax \ifnum#1=1\relax \glssubentryitem{#2}% \fi \glstreenamefmt{\glstarget{#2}{\glossentryname{#2}}}% \ifglshassymbol{#2}{\space(\glsentrysymbolname{#2})}{}% \glstreechildpredesc\glossentrydesc{#2}\glspostdescription\space #3\par }%

% *******************************************

\usepackage{amsmath,bm,times}

\makenoidxglossaries

\newglossaryentry{subsytem}{name={Subssytems},description={\glspar},sort={4}}
\newglossaryentry{compressor} { name={Compressor}, text={compressor}, sort={compressor}, description={Air Compressor}, symbol={cp}, symbolname={\textcolor{red}{123Cpxx}},% added <<<<<<<<<<<<<<<<<<< parent=subsytem }

\newglossaryentry{compressor_motor} { name={Compressor Motor}, sort={compressor motor}, text={compressor motor}, description={Motor of the \Gls{compressor}}, symbol={cm}, symbolname={456CMxx},% added <<<<<<<<<<<<<<<<<<< parent=subsytem }

\newglossaryentry{compressor_valve}% symbolname is not defined <<<<<<<<<<<< { name={Compressor Valve}, sort={compressor valve}, text={compressor valve}, description={Valve of the \Gls{compressor}}, symbol={vv}, parent=subsytem }

\newglossaryentry{PQ}{name={Physical Quantities},description={\glspar},sort={5}} \newglossaryentry{Qcp} { name={$\mathbf{\bm{Q}}_{\glssymbol{compressor},out}$}, sort={Qcpout}, text={\Glssymbol{compressor} Air Outlet Mass Flow Rate}, description={Compressor Air Outlet Mass Flow Rate}, symbol={cp}, symbolname={FlowRate},% added <<<<<<<<<<<<<<<<<<< parent=PQ }

\begin{document}

\gls{compressor_valve};
\gls{compressor_motor};
\gls{compressor}

\bigskip    

\gls{Qcp}

\printnoidxglossary

\end{document}

Check using beamer class

% !TeX TS-program = pdflatex

\documentclass[11pt]{beamer}

....

\begin{document}
\begin{frame}[plain]
    \maketitle
\end{frame}

\begin{frame}
    \frametitle{}       
    \gls{compressor_valve};
    \gls{compressor_motor};
    \gls{compressor}        
    \bigskip    

    \gls{Qcp}
\end{frame}

\begin{frame}
\frametitle{Glossary}       
\printnoidxglossary
\end{frame}

\end{document}

ab

Simon Dispa
  • 39,141
  • Thanks a lot ! This is exaclty what I asked for ! However, after some tests I wonder If it would be possible to use the "symbol" field by default (to print the glossary) if the "symbolname" field is not declared ? – zetyty Jan 27 '22 at 20:43
  • @Sylvain Rigal Thank you for your feedback!. Your suggestion improves the code. Please see the updated answer. – Simon Dispa Jan 27 '22 at 22:32
  • Perfect Thanks a lot ! And it works if "symbol" AND "symbolname" fields are not defined ! Just a little remark : a "}" is missing at the end of your code "\end{document" ;) Thank you again, this is exactly what I need ! – zetyty Jan 28 '22 at 15:54
  • @Sylvain Rigal Done! Thank you for your last feedback! – Simon Dispa Jan 28 '22 at 16:34
  • You put a ")" instead of a "}" ;) Sorry... – zetyty Jan 28 '22 at 20:19
  • @Sylvain Rigal Not my best day! – Simon Dispa Jan 28 '22 at 20:53
  • This solution doesn’t work with Beamer class. Do you know by chance how to make it works with Beamer ? – zetyty Feb 03 '22 at 17:55
  • @ Please try the Updated(2) answer. – Simon Dispa Feb 03 '22 at 19:26
  • Just Perfect ! Thanks ! – zetyty Feb 03 '22 at 22:25
  • @Sylvain Rigal Over time it will converge on a very good solution! – Simon Dispa Feb 03 '22 at 22:42
  • I have a new request sorry! It seems that this code disable the display of all glossary entries with a level upper than 3. That means, only the 3 first levels of the glossary are printed in the glossary print and if I remove your piece of code dealing with the symbolname field, then all the glossary levels apears correctly in the glossary print... – zetyty Mar 03 '22 at 09:52
  • @SylvainRigal I do not understand the issue. Could you please provide an example of the desired output? Perhaps in another question .... ? – Simon Dispa Mar 04 '22 at 19:47
  • Finally it works perfectly! The problem was that I used an old version of your solution (I don't know why). I found the problem while working on the new question (luckily you offered me to ask a new one!). So I'm sincerely sorry and thank you very much for your support. – zetyty Mar 04 '22 at 20:25
  • @SylvainRigal I'm glad my insignificant help helped! – Simon Dispa Mar 04 '22 at 20:52