[Tex/LaTex] Suppress \gls links on one glossary only

glossarieshyperref

I want to use \gls* automatically when invoking the \gls command. This should be done for one glossary (type=tech) only and globally.

Not working:

  • \glsdisablehyper does not work at the define level, only in the document. That would take away all other links as well.
  • \newglossaryentry[hyper=false] does not do the thing I want.
  • Replace \gls with \gls* manually? Not that nice…

Any other ideas? Like defining an own style that does not use the link function? I'm a bit lost on this one.

Edit: Here is a minimal example: Gist

\documentclass[german,pagesize,BCOR=0mm,titlepage,toc=bib,headinclude,headsepline]{book}
\tableofcontents
\usepackage[pdfusetitle,pdftex,colorlinks]{hyperref}


% DOCUMENTATION HERE:
% http://www.latex-community.org/know-how/263-glossaries-nomenclature-lists-of-symbols-and-acronyms
% °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
% INCLUDE THIS EVER TIME!!!
%\newglossary[⟨log-ext⟩]{⟨name⟩}{⟨in-ext⟩}{⟨out-ext⟩} {⟨title⟩}[⟨counter ⟩]
\usepackage[acronym]{glossaries}
\newglossary{opad}{gls}{glo}{Technical and Research Terms}
\newglossary{tech}{tgls}{tglo}{Software and Libraries}
\newglossary[glignoredl]{ignored}{glignored}{glignoredin}{Ignored Glossary}

\makeglossaries  

% ==============================================================================
% STYLING
% ==============================================================================

\defglsdisplayfirst[ignored]{\textit{#1}}
\defglsdisplay[ignored]{#1}   

\defglsdisplayfirst[opad]{\textit{#1}}
\defglsdisplay[opad]{#1}

% TODO@IMPORTANT: How to highlight the tech terms? Declare them in the intro!!!
\defglsdisplayfirst[tech]{\textbf{{#1}}}
\defglsdisplay[tech]{ \textbf{{#1}} }

\defglsdisplayfirst[acronym]{\textit{#1}}
\defglsdisplay[acronym]{#1}  


\renewcommand*{\firstacronymfont}[1]{\normalfont{#1}}
\renewcommand*{\acronymfont}[1]{\normalfont{#1}}

% I want this: http://tex.stackexchange.com/questions/25805/disable-hyperlinks-in-some-entries-for-glossaries !!!
% TODO@GLOSS put gls* behind all links of type ignore. baaaah :(
\newglossaryentry{withoutlink}{  
  type=tech, name={withoutlink},
  description={withoutlink} }
  }

\newglossaryentry{withlink}{ 
  type=tech, name={withlink},
  description={withlink} }  
  }

% ==============================================================================
  \begin{document} 

  \section{Manual Test}

    \subsection{Gloss}
    \gls*{withoutlink} (gls*)... Okay, that behavior can be done with starring gls. But I dont want to do this in my whole document since sometimes I muse gloss from the ignored type to the used type.\\

    \noindent
    \gls{withoutlink} (gls)... this should be without link by setting something in the \texttt{\defglsdisplay[ignored]{#1}} or so

    \noindent   
    \gls{withlink}... This is just the normal behavior
    \ \\

  %\section{Ignored Gloss}
  %\printglossary[type=ignored, title={Ignored Glossary. Don't show this in production!}]

  \printglossary[type=opad] 
  \printglossary[type=tech] 

  \end{document}

Best Answer

I think the easiest way is to redefine the internal command \@gls@. Inside the command you can detect which type is used and enable the hyperlinks if the type is tech:

\makeatletter

\def\@gls@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
\def\templocal{tech}%
\ifx\@glo@type\templocal\relax%
\def\@gls@link@opts{hyper=false,#1}%
\else
\def\@gls@link@opts{#1}%
\fi%
\def\@gls@link@label{#2}%
\ifglsused{#2}%
{%
  \def\@glo@text{%
    \csname gls@\@glo@type @display\endcsname
      {\glsentrytext{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
{%
  \def\@glo@text{%
    \csname gls@\@glo@type @displayfirst\endcsname
      {\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
\ifglsused{#2}{%
 \ifx\@glo@type\templocal\relax%
  \@gls@link[hyper=false,#1]{#2}{\@glo@text}%
 \else%
  \@gls@link[#1]{#2}{\@glo@text}%
 \fi %
}{%
  \gls@checkisacronymlist\@glo@type
  \ifthenelse{\(\boolean{@glsisacronymlist}\AND
    \boolean{glsacrfootnote}\) \OR \NOT\boolean{glshyperfirst}}{%
    \@gls@link[#1,hyper=false]{#2}{\@glo@text}%
  }{%
   \ifx\@glo@type\templocal\relax%
    \@gls@link[hyper=false,#1]{#2}{\@glo@text}%
   \else%
    \@gls@link[#1]{#2}{\@glo@text}%
   \fi %
  }%
}%
\glsunset{#2}}%
}
\makeatletter

Here the complete example:

\documentclass[german,pagesize,BCOR=0mm,titlepage,toc=bib,headinclude,headsepline]{book}

\usepackage[pdfusetitle,pdftex,colorlinks]{hyperref}
\usepackage[acronym]{glossaries}
\newglossary{opad}{gls}{glo}{Technical and Research Terms}
\newglossary{tech}{tgls}{tglo}{Software and Libraries}
\newglossary[glignoredl]{ignored}{glignored}{glignoredin}{Ignored Glossary}

\makeglossaries  

\defglsdisplayfirst[ignored]{\textit{#1}}
\defglsdisplay[ignored]{#1}   

\defglsdisplayfirst[opad]{\textit{#1}}
\defglsdisplay[opad]{#1}


\defglsdisplayfirst[tech]{\textbf{{#1}}}
\defglsdisplay[tech]{ \textbf{{#1}} }

\defglsdisplayfirst[acronym]{\textit{#1}}
\defglsdisplay[acronym]{#1}  


\renewcommand*{\firstacronymfont}[1]{\normalfont{#1}}
\renewcommand*{\acronymfont}[1]{\normalfont{#1}}

\newglossaryentry{withoutlink}{  
  type=tech, name={withoutlink},
  description={withoutlink} }


\newglossaryentry{withlink}{ 
  type=tech, name={withlink},
  description={withlink} }  
\makeatletter

\def\@gls@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
\def\templocal{tech}%
\ifx\@glo@type\templocal\relax%
\def\@gls@link@opts{hyper=false,#1}%
\else
\def\@gls@link@opts{#1}%
\fi%
\def\@gls@link@label{#2}%
\ifglsused{#2}%
{%
  \def\@glo@text{%
    \csname gls@\@glo@type @display\endcsname
      {\glsentrytext{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
{%
  \def\@glo@text{%
    \csname gls@\@glo@type @displayfirst\endcsname
      {\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
\ifglsused{#2}{%
 \ifx\@glo@type\templocal\relax%
  \@gls@link[hyper=false,#1]{#2}{\@glo@text}%
 \else%
  \@gls@link[#1]{#2}{\@glo@text}%
 \fi %
}{%
  \gls@checkisacronymlist\@glo@type
  \ifthenelse{\(\boolean{@glsisacronymlist}\AND
    \boolean{glsacrfootnote}\) \OR \NOT\boolean{glshyperfirst}}{%
    \@gls@link[#1,hyper=false]{#2}{\@glo@text}%
  }{%
   \ifx\@glo@type\templocal\relax%
    \@gls@link[hyper=false,#1]{#2}{\@glo@text}%
   \else%
    \@gls@link[#1]{#2}{\@glo@text}%
   \fi %
  }%
}%
\glsunset{#2}}%
}
\makeatletter

\begin{document} 
\tableofcontents
  \section{Manual Test}

    \subsection{Gloss}
    \gls*{withoutlink} (gls*)... Okay, that behavior can be done with starring gls. But I dont want to do this in my whole document since sometimes I muse gloss from the ignored type to the used type.\\

    \noindent
    \gls{withoutlink} (gls)... this should be without link by setting something in the    \texttt{\string\defglsdisplay[ignored]{\#1}} or so

    \noindent   
    \gls{withlink}... This is just the normal behavior
    \ \\

  %\section{Ignored Gloss}
  %\printglossary[type=ignored, title={Ignored Glossary. Don't show this in production!}]

  \printglossary[type=opad] 
  \printglossary[type=tech] 

  \end{document}
Related Question