I am currently trying to use a glossary entry in the labels of a PGFPlot.
E.g. ylabel={$\gls{F}_h\ in\ \glsunit{F}}.
I set up glsunit according to How to use glossary entry in siunitx command?. Inside text this is working fine, just not in the PGFPlot. There the symbols only appear as ???.
Further info: I am using tikz externalize for the plots and use a bib file and bib2gls for the symbols.
Is there a way to resolve the symbols inside the PGFPlot?
the stripped down example:
\begin{filecontents*}{symbols.bib}
@entry{F,
name={\ensuremath{F}},
description={Force},
unit={\si{\newton}}
}
@entry{s,
name={\ensuremath{s}},
description={Normalised Distance},
unit={}
}
\end{filecontents*}
\documentclass{article}
\usepackage[british]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%\usepackage[colorlinks=true, linkcolor=black, citecolor=blue, urlcolor=blue]{hyperref}
\usepackage{siunitx}
\usepackage[record, abbreviations, nonumberlist]{glossaries-extra}
\setabbreviationstyle{long-short}
\newglossary[slg]{symbols}{syi}{syg}{Symbols}
\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}
\glssetnoexpandfield{unit}
\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
\begin{longtable}{lp{\glsdescwidth}>{\centering\arraybackslash}p{2cm}}}%
{\end{longtable}}%
%
\renewcommand*{\glossaryheader}{% Change the table header
\bfseries Sign & \bfseries Description & \bfseries Unit \\
\hline
\endhead%
}
\renewcommand*{\glossentry}[2]{% Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glossentrydesc{##1}% Description
& \glsunit{##1} \tabularnewline
}
}
\GlsXtrLoadResources[src={symbols}, type={symbols}]
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\pgfplotsset{compat=1.16}
% \tikzexternalize[
% mode=list and make,
%% force remake,
% ]
\begin{document}
\printunsrtglossary[type=symbols, style=symbunitlong]
Just a test with \gls{s} and \gls{F} in \glsunit{F}. \\
%
\begin{tikzpicture}
\begin{axis}[
xlabel={\gls{s}},
ylabel={$\gls{F}\ in\ \glsunit{F}$},
]
\addplot[color=red,mark=x] coordinates {
(2,-2.8559703)
(3,-3.5301677)
(4,-4.3050655)
(5,-5.1413136)
(6,-6.0322865)
(7,-6.9675052)
(8,-7.9377747)
};
\end{axis}
\end{tikzpicture}
\end{document}
\documentclass{...}and ending with\end{document}. – Stefan Pinnow Mar 23 '20 at 16:04/tikz/external/mode=list and maketo make it work. See the tikz manual or PGFPlots manual for details. – Stefan Pinnow Mar 23 '20 at 16:09??, not only in thetikzpictureoraxisenvironment. Please modify it again and/or describe in comments or the normal text what to do so that at least the stuff outsidetikzpictureshows up. – Stefan Pinnow Mar 23 '20 at 17:09??s and nothing in "Symbols" section ... – Stefan Pinnow Mar 23 '20 at 17:43externallibrary isn't used and it doesn't work in theaxisenvironment when theexternallibrary is used. Unfortunately I don't know why. Maybe @NicolaTalbot has an idea why !?!? – Stefan Pinnow Mar 23 '20 at 18:34