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)...

1
  • +1 Your question is very well formulated and complete. Commented Jan 27, 2022 at 22:41

1 Answer 1

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

14
  • 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
    Commented Jan 27, 2022 at 20:43
  • @Sylvain Rigal Thank you for your feedback!. Your suggestion improves the code. Please see the updated answer. Commented Jan 27, 2022 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
    Commented Jan 28, 2022 at 15:54
  • @Sylvain Rigal Done! Thank you for your last feedback! Commented Jan 28, 2022 at 16:34
  • You put a ")" instead of a "}" ;) Sorry...
    – zetyty
    Commented Jan 28, 2022 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .