I set custom gls text format with the following command:
\renewcommand*{\glstextformat}[1]{\textcolor{red}{\textbf{#1}}}
But, sometimes, I don't want this format locally for a Tikzpicture, a table or the glossary list for example.
Here a MWE:
\documentclass{article}
\usepackage[style=tree]{glossaries-extra}
\usepackage{xcolor}
\usepackage{tikz}
\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
}
% My custom gls text format !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\renewcommand*{\glstextformat}[1]{\textcolor{red}{\textbf{#1}}}
\begin{document}
In text I want custom gls format (bold and red) :
\gls{compressor_motor}
\gls{compressor}
But in tables, tikzfigure, glossary I don't want it (I want default format) :\
\begin{tabular}{rr}
\hline
\Glssymbol{compressor} & 1 \
\hline
1 & 2.36 \
\hline
\end{tabular}
\begin{tikzpicture}%
\node (CpMap) [draw, fill=blue!20, text width=5em,text centered, minimum height=2.5em] {\Glssymbol{compressor}};
\end{tikzpicture}%
\printnoidxglossary
\end{document}
So, instead of this result:
I would like something like that:
I obtain this result by enclosing the part, where I dont want gls formatting, by these two lines (for exemple with a Tikzfigure):
\renewcommand*{\glstextformat}[1]{{#1}}% Set none gls text format
\begin{tikzpicture}%
\node (CpMap) [draw, fill=blue!20, text width=5em,text centered, minimum height=2.5em] {\Glssymbol{compressor}};
\end{tikzpicture}%
\renewcommand*{\glstextformat}[1]{\textcolor{red}{\textbf{#1}}}% Restore custom gls text format
Which is really not practical.
I tried to create a new environment which do this enclosing, but I didn't succeed...
EDIT #1 01/28/22 - Clarification: I specify that I use the "colored" format (see at the very beginning) most often. So I would prefer that this format be available "by default" when I use all the classic commands (\Gls, \gls, \glssymbol, etc.). (This is why I redefining the global default format of gls links with \glstextformat.)
And only in certain cases, I would like to be able to remove this "colored" format for another format that I have chosen (a "normalfont" would also suffice for my needs).
Indeed, it would be too cumbersome for me to have to use other commands (other than the classic gls commands) to use the "colored" format when it's the one I use most often. On the contrary, I don't mind having to do an additional manipulation when I DO NOT want the "colored" format because it's a rarer case for me...
EDIT #2 01/28/22 - Feedback: DG's solution- with the use of \gls[textformat={normalfont}]{compressor} - answers my question. However, after some test I see that it not well suits my needs (not fully visible in my original question). In fact I often define an gls entry by another one like (for exemple with the name field and the description field):
\newglossaryentry{compressor_motor}
{
name={\glsname[textformat={normalfont}]{compressor} Motor},
sort={compressor motor},
text={compressor motor},
description={Motor of the \Gls[textformat={normalfont}]{compressor}},
symbol={cm},
parent=subsytem
}
So, if I do that I will obtain the following result:
With the following code:
\documentclass{article}
\usepackage[style=tree]{glossaries-extra}
\usepackage{xcolor}
\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={\glsname[textformat={normalfont}]{compressor} Motor},
sort={compressor motor},
text={compressor motor},
description={Motor of the \Gls[textformat={normalfont}]{compressor}},
symbol={cm},
parent=subsytem
}
% My custom gls text format !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\renewcommand*{\glstextformat}[1]{\textcolor{red}{\textbf{#1}}}
\begin{document}
\glsdesc{compressor_motor}
\printnoidxglossary
\end{document}
As you can see some font (bold) problems occurs (red ellipsis only, rectangle is Ok) as Simon Dispa pointed out in comment. But the [textformat={normalfont}] solution is powerfull because it permits to obtain the red color in text - when \glsdesc is used - but not the bold format.
So, I don't know what to do... Maybe I can use the Simon Dispa solution and create new fields like \glscol, \glssymbolcol \glsnamecol, etc. for all my needs and don't touch the global font with redefining the \glstextformat command. However, this method is quite cumbersome for daily use...
I would be glad to have a solution to locally change the global gls link font as a new environment or something... But if it's not possible I'm ready to let go...







glossaries-extrahas some formatting options that may help you: https://www.dickimaw-books.com/gallery/index.php?label=sample-name-font – DG' Jan 27 '22 at 10:39