# Position of powers/subscripts when using symbols/symbolslist via glossaries

I'm using the glossaries package to generate a symbols table from the document I'm writing, which works fine.

However, today I noticed that the symbols are than treated as a new object and if powers, e.g. ^1, are added, these are misplaced.

Any idea how to fix this?

Working example (note that I'm using lualatex, but it shouldn't matter, if you comment the lualatex-specific parts it should work with latex):

\documentclass[
paper=a5,
pagesize,
fontsize=10pt,
DIV=calc,
BCOR=12mm,
twoside,
open=right,
]{scrreprt}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

%% LuaTex

\usepackage{unicode-math} % Allow unicode symbols in formulas, Option [math-style=ISO]?
%\usepackage[final]{microtype} % Micro-adaption (i.e. spaces) of fonts
% \defaultfontfeatures{Scale=MatchLowercase} Test
\newfontfeature{Microtype}{protrusion=default;expansion=default;}
\directlua{fonts.protrusions.setups.default.factor=.5}
\setmainfont[Microtype,Ligatures=TeX]{Linux Libertine O} % Select Linux Libertine as main font with advanced features
\setsansfont[Microtype,Ligatures=TeX]{Linux Biolinum O} % Select Sans Font
\setmathfont[Microtype,Ligatures=TeX]{XITS Math} % Setze Schriftart der Matheumgebung

\usepackage{scrpage2} % KOMA-Script
\usepackage[toc]{glossaries}

\newglossary[slg]{symbolslist}{syi}{syg}{Symbols}

% New style, basically to insert units.
\newglossarystyle{symbols}{%
% Defined as longtable with 4 columns
\renewenvironment{theglossary}%
{\begin{longtable}{llp{\glsdescwidth}p{\glspagelistwidth}}}%
{\end{longtable}}%
\bfseries Symbol & \bfseries Unit & \bfseries Description & \bfseries  Pages  %
% No spacer between the groups
%
\renewcommand*{\glossaryentryfield}[5]{%
%   \glsentryitem{##1}% Entry number if required
\glstarget{##1}{##2}% Name
& \glsentryuseri{##1}% Value/Unit
& ##3% Description
& ##5% Page list
\\% end of row
}%
% The command \glsgroupskip specifies what to do between glossary groups.
% Glossary styles must redefine this command. (Note that \glsgroupskip
% only occurs between groups, not at the start or end of the glossary.)
\renewcommand*{\glsgroupskip}{\relax}
}
% To shorten the notation
\newcommand{\symb}[1]{\gls{symb:#1}}

\newglossaryentry{symb:A}{
name={\ensuremath{A_0}},
description={Test Parameter},
user1={m},
sort=A, type=symbolslist
}

%\title{symbols-test}
%\author{}
%\date{}

\makeglossaries

\begin{document}

blabla
\begin{align}
\symb{A} \\
\symb{A}^1 \\
A_0^1
\end{align}

\printglossary[type=symbolslist,style=symbols]

\end{document}

• I don't think that there is a solution with linked symbols, but \glsentrytext{symb:A}^1 or \glsentryfirst{symb:A}^1 and similar would work. – Ulrike Fischer Jul 22 '16 at 7:34
• Yes indeed, that does work, but unfortunately, that's no use to me. The linked symbols are the reason why I'm doing this, otherwise it would be easier (and better to read in the code) to just write out the symbols each time. – Bernd Steinhauser Jul 22 '16 at 9:23
• Since in my case this is mostly related to superscripts, I thought about introducing an optional parameter to \symb, so that \symb{A}{1} would yield A_0^1. However, this would require a modification of \gls, which I fear I know too little about. Maybe someone could help with that approach? – Bernd Steinhauser Jul 22 '16 at 10:10

Be careful when you use glossary entries in math mode especially if you are using hyperref as it can affect the spacing of subscripts and superscripts.

You need to put the super/subscript in the final optional argument of \gls. For example \gls{symb:A}[^1].

\documentclass{scrreprt}

\usepackage[toc]{glossaries}

% To shorten the notation
\newcommand{\symb}[1]{\gls{symb:#1}}

\newglossaryentry{symb:A}{
name={\ensuremath{A_0}},
description={Test Parameter},
user1={m},
sort=A,
}

\makeglossaries

\begin{document}

blabla
\begin{align}
\symb{A} \\
\symb{A}^1 \\
\symb{A}[^1] \\
A_0^1
\end{align}

\printglossary

\end{document}


This produces:

• Thanks, I can't try it right now, but indeed that will work (now that thanks to you I found the right spot in the docs). And the good thing is that the changes I will have to make are minimal, just have to add the [] where necessary. – Bernd Steinhauser Jul 22 '16 at 19:54