我想\gls*
在调用\gls
命令时自动使用。这应该只针对一个词汇表 () 进行type=tech
,并且是全局性的。
不工作:
\glsdisablehyper
不适用于定义级别,仅适用于文档。这也会带走所有其他链接。\newglossaryentry[hyper=false]
没有做我想要的事情。\gls
手动替换\gls*
?不太好……
还有其他想法吗?比如定义不使用链接功能的自己的样式?我对这个有点迷茫。
编辑:这是一个最小的例子:要旨
\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}
答案1
我认为最简单的方法是重新定义内部命令\@gls@
。在命令内部,您可以检测使用的类型,如果类型为 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
完整的例子如下:
\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}