Text Formattinghyperref and glossaries in subscripts

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
tyltus
Posts: 12
Joined: Tue Nov 10, 2009 12:03 pm

hyperref and glossaries in subscripts

Post by tyltus »

Hello

In my report I would like to make a glossary for commonly used index that are usually placed in subscripts. This works just fine with the glossaries package - but when I want to improve the document for pdf-reading by adding the hyperref package the sizes and the fonts are changed.

Here a mini example:

Code: Select all

\documentclass{article}

\usepackage[pdfborder={0 0 0 0}]{hyperref}
\usepackage{glossaries}

\makeglossaries
\newglossaryentry{u}{name={u},description={some commonly used index}}
\newglossaryentry{m}{name=\ensuremath{m}, description={another index}}

\begin{document}
% outside math mode hyperref doesn't change anything:
u \gls{u} m \gls{m}\\
% inside math mode the output looks different when hyperlink is used to when it's not
$u \gls{u}$ $m \gls{m}$\\
$a_u=a_{\gls{u}}\qquad a_{\gls{u}u}$
\end{document}
When I leave out the \usepackage{hyperref}, the output is as desired that you see no difference between the glossary letters and the normal letters (unless that \gls{m} is allways printed in math mode). But when hyperref is used, the format of the glossary entry seems to be reset, so normal mode is used unless math mode is specifically set by \ensuremath and more importantly the subscript letters are printed in textsize.
The goal is, that the glossary subscripts should be linked but not visibly different from non-glossary subscripts. So, how can I get the layout to stay the same whether I use the hyperref package or not?

Is this just a problem with my compiler? I'm using TexnicCenter and the glossaries.bat file to compile and I do get the message "couldn't find input index file" but until now this didn't cause any problems.
Or is there a set of options or any other way to achieve that hyperref doesn't change the text formating?

Any help on this would be very much welcome
Best regards
Martin

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Re: hyperref and glossaries in subscripts

Post by nlct »

I can't see a difference with the latest version of the glossaries package. What version of glossaries are you using? (Check the log file or use \listfiles).

Regards
Nicola Talbot
tyltus
Posts: 12
Joined: Tue Nov 10, 2009 12:03 pm

Re: hyperref and glossaries in subscripts

Post by tyltus »

Hello

Ok, so this means that it is a problem with the compiler and not with the program itself, that's allready good to know :)

But I just did an update of all my packages and that didn't help. What else could I try to do? Or what exactly would you need to be able to help me with this problem?
tyltus
Posts: 12
Joined: Tue Nov 10, 2009 12:03 pm

Re: hyperref and glossaries in subscripts

Post by tyltus »

Oh, the problem is narrowing down:
When I use the Latex => PDF compiler option, the outputs are indeed as expected! The problem only occurs when I use the Latex => PS => PDF option, which I need for my final report because I'm using PStricks.

Here the compiler options:

Latex => PDF
compiler:
pdflatex.exe -interaction=nonstopmode "%pm"
makeindex.exe "%bm"
Postprocessor:
makeglossaries.bat "%bm"

Latex => PS => PDF
compiler:
latex.exe --src -interaction=nonstopmode -max-print-line=120 "%Wm"
makeindex.exe "%bm"
Postprocessor:
dvips.exe -P pdf -R0 "%Bm.dvi"
gswin32c.exe -sPAPERSIZE=a4 -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="%bm.pdf" -c save pop -f "%bm.ps"
makeglossaries.bat "%bm"

The compilers and the arguments come from a profile provided by Localghost somewhere else in this community, exept for the aded makeglossaries.bat.

I hope this information helps in solving that problem!
Best regards
Martin
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

hyperref and glossaries in subscripts

Post by nlct »

Okay, using LaTeX I can see the problem now. (I always use PDFLaTeX and didn't think to test it with LaTeX.) This problem isn't specific to the glossaries package. It can be demonstrated with the following minimal example:

Code: Select all

\documentclass{article}
\usepackage[colorlinks]{hyperref}
\begin{document}
$a_{\hyperlink{target}{u}}\qquad a_{u}$
\end{document}
I don't know how to get around it without using PDFLaTeX.

Regards
Nicola Talbot
tyltus
Posts: 12
Joined: Tue Nov 10, 2009 12:03 pm

hyperref and glossaries in subscripts

Post by tyltus »

Since this problem seemed to be independant of the glossaries package I opend a new thread for the more general case.

The fix for a normal hyperlink is easy enough: (thank you frabjous)
frabjous wrote: It looks like the latex version takes it out of math mode.

Try this:

Code: Select all

    \documentclass{article}
    \usepackage[colorlinks]{hyperref}
    \begin{document}
    $a\hyperlink{target}{\ensuremath{_{u}}}\qquad a_{u}$
    \end{document}
That looks the same to me with both latex and pdflatex.
So, does someone see a way how to apply this fix when using the glossaries package? Unfortunately not all my glossary entries are supposed to be in math mode which complicates the matter :S

Best regards
Martin
Post Reply