4

I use the acronyms package to define mathematic symbols like this:

\begin{acronym}[long]
\acro{v}[$\vec{v}$]{View direction vector}
\end{acronym}

I do this with lots of others where it is faster to type \acs{<short>} instead of the long math mode expression.

When I use this, the hyperref package makes the output be formatted in a certain color. I like that for acronyms like GPS where I want the reader to see that the short version is clickable. For those I use a different list of acronyms similar to the one above.

But I don't want the mathematical expressions be colored in equations, because it disturbs readability if some are defined as acronyms and others are written manually.

My question is now: Can I make hyperref remove the color of the links from a specific list of acronyms? Or can I turn off the link coloring for math mode?

This is my first question here, I hope I made my problem clear :-)


Added example: (I'm using classicthesis and arsclassica which make the links colored but it should not matter where the colors come from)

\documentclass{scrreprt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% REQUIRED FOR ARSCLASSICA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{subfig}
\usepackage[strict]{changepage}
\usepackage[parts,dottedtoc,eulerchapternumbers,subfig,beramono,pdfspacing] {classicthesis}
\usepackage{arsclassica}

% hyperref and acronym
\usepackage{hyperref}
\usepackage{acronym}

\begin{document}
    \chapter{Text}
    Some text where I want to have \ac{BRDF} as a visibly colored link and in 
    an equation would not want the symbol to be a colored link.

    \begin{equation}
        \acs{fBRDF} = \dots
    \end{equation}

    However it would be nice if it still was a link. It just should not have 
    any color.

    % Two acronym lists
    \chapter{List of Abbreviations}
    \begin{acronym}[GPS]
        \acro{BRDF}{Bidirectional Reflectance Distribution Function}
        \acro{RGB}{Red, Green, Blue}
    \end{acronym}

    \chapter{List of Symbols}
    \begin{acronym}[$f(\vec{l},\vec{v})$]
        \acro{fBRDF}[$f(\vec{l},\vec{v})$]{\acf{BRDF}}
    \end{acronym}

\end{document}
  • 1
    \hypersetup{colorlinks=false} in the preamble should work, but this will remove any colored link (i.e. the link is there, but it's the default black textcolor) – user31729 Feb 16 '15 at 11:21
  • 1
    In addition: Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Feb 16 '15 at 11:22
  • Yep, if I turn off the colored links it looks fine. But I don't want the abbreviations outside equations to be black. They should still be colored. I particularly only want to deactivate coloring the ones defined in the second list, or alternatively in math mode in general. – dnlbschff Feb 16 '15 at 12:48
2

It's possible to set the link color inside of an environment temporarily to another value (other than specified before) and to restore it to the original one afterwards.

I used the xpatch package to append the color change code after the start of the equation environment (macro \equation) and to switch back after \endequation (which is \end{equation} effectively).

For better convenience I defined the commands \DefaultDocumentLinkColor and \DefaultDocumentEquationLinkColor to hold the color names.

However, the equation link is not recognizable as such using the normal text color.

\documentclass{scrreprt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% REQUIRED FOR ARSCLASSICA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{subfig}
\usepackage[strict]{changepage}
\usepackage[parts,dottedtoc,eulerchapternumbers,subfig,beramono,pdfspacing]{classicthesis}
\usepackage{arsclassica}

% hyperref and acronym

\usepackage{xpatch}

\newcommand{\DocumentDefaultLinkColor}{blue}
\newcommand{\DocumentDefaultEquationLinkColor}{black}


\usepackage{hyperref}
\usepackage{acronym}

\hypersetup{linkcolor={\DocumentDefaultLinkColor}}


\xapptocmd{\equation}{\hypersetup{linkcolor={\DocumentDefaultEquationLinkColor}}}{}{}%
\xapptocmd{\endequation}{\hypersetup{linkcolor={\DocumentDefaultLinkColor}}}{}{}%

\begin{document}
    \chapter{Text}
    Some text where I want to have \ac{BRDF} as a visibly colored link and in 
    an equation would not want the symbol to be a colored link. See \ref{listofsymbols}

    \begin{equation}
        \acs{fBRDF} = \dots
    \end{equation}

    However it would be nice if it still was a link. It just should not have 
    any color.

    % Two acronym lists
    \chapter{List of Abbreviations}
    \begin{acronym}[GPS]
        \acro{BRDF}{Bidirectional Reflectance Distribution Function}
        \acro{RGB}{Red, Green, Blue}
    \end{acronym}

    \chapter{List of Symbols} \label{listofsymbols}
    \begin{acronym}[$f(\vec{l},\vec{v})$]
        \acro{fBRDF}[$f(\vec{l},\vec{v})$]{\acf{BRDF}}
    \end{acronym}

\end{document}

enter image description here

  • @dnlbschff: Alright... but I find it still a little bit awkward that the links are not recognizable as such any longer – user31729 Feb 16 '15 at 14:23
  • Yeah, I'm thinking about turning the links off completely in the equation. The point for me is only to have short versions for mathematic symbols that are automatically added to the list of symbols whe I use them. However, I have trouble getting to run this solution on a Windows environment with Miktex. On my Ubuntu Laptop everything is fine. But on win I get Package xparse Error: Support package l3kernel too old.... – dnlbschff Feb 16 '15 at 14:26
  • 1
    @dnlbschff: You should update your MikTeX distribution then... I update everyday from TeXLive ;-) – user31729 Feb 16 '15 at 14:45
  • 1
    @dnlbschff: Ah, that's tricky.... however, if you change $...$ to \(...\)$ the same stuff could be applied to (` like I've done for \equation and to \) to \endequation. For the $ I am unsure at the moment – user31729 Feb 16 '15 at 16:39
  • 1
    See for example tex.stackexchange.com/questions/59980/can-i-redefine-the-dollar, but I don't encourage you to redefine $...$ at all, since you have some \begin{acronym}{$...$} ... it would apply for them to--> no good idea ;-) – user31729 Feb 16 '15 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.