词汇表-额外: Hyperref/Link 仅指向每章中第一次出现的条目

词汇表-额外: Hyperref/Link 仅指向每章中第一次出现的条目

我想要和这个问题一样的东西但是带有glossaries-extra包: 词汇表:Hyperref/Link 仅指向每章中第一次出现的条目

我尝试过 \glssetcategoryattribute{glossary}{nohyper}{true}

其余的和链接中的一样。但是它不起作用。有人能告诉我如何让它工作吗?

\documentclass{report}
\usepackage{etoolbox}
\usepackage[colorlinks]{hyperref}
\usepackage[automake=immediate,toc,
abbreviations,
symbols,
postdot, 
hyperfirst=false,
nopostdot=true, nonumberlist=true,
 ]{glossaries-extra}

\newglossary[ilg]{glossary}{iyi}{iyg}{ML Gloassary}

\glssetcategoryattribute{glossary}{nohyper}{true}
\preto\chapter{\glsresetall}

\makeglossaries

\renewcommand{\glsentryfmt}{%
    \ifglsused{\glslabel}
    {\glsgenentryfmt}% entry has been used.
    {\glshyperlink[\glsgenentryfmt]{\glslabel}}% entry hasn't been used
}


\newglossaryentry{apple}{
 type=glossary,
  name={apple},
  description={small round fruit}
}

\newglossaryentry{pear}{
  type=glossary,
  name={pear},
  description={small non-round fruit}
}

\begin{document}

\chapter{Sample}

\section{No Case Change}

Singular: \gls{apple}. Plural: \glspl{apple}.

Singular: \gls{pear}. Plural: \glspl{pear}.

\section{First Letter Uppercase}

Singular: \Gls{apple}. Plural: \Glspl{apple}.

Singular: \Gls{pear}. Plural: \Glspl{pear}.

\section{All Uppercase}

Singular: \GLS{apple}. Plural: \GLSpl{apple}.

Singular: \GLS{pear}. Plural: \GLSpl{pear}.

\chapter{Another Sample}

\section{No Case Change}

Singular: \gls{apple}. Plural: \glspl{apple}.

Singular: \gls{pear}. Plural: \glspl{pear}.

\section{First Letter Uppercase}

Singular: \Gls{apple}. Plural: \Glspl{apple}.

Singular: \Gls{pear}. Plural: \Glspl{pear}.

\section{All Uppercase}

Singular: \GLS{apple}. Plural: \GLSpl{apple}.

Singular: \GLS{pear}. Plural: \GLSpl{pear}.

\printglossaries

\end{document}

答案1

我在一些人的帮助下解决了这个问题。代码如下:

\usepackage{etoolbox}
\usepackage[colorlinks]{hyperref}
\usepackage[automake=immediate,toc,
abbreviations,
symbols,
postdot, 
hyperfirst=false,
nopostdot=true, nonumberlist=true
 ]{glossaries-extra}

\newglossary[ilg]{glossary}{iyi}{iyg}{ML Gloassary} % create add. symbolslist

\makeglossaries

\GlsXtrEnableEntryUnitCounting{general}{0}{chapter}
\GlsXtrEnableEntryUnitCounting{abbreviation}{0}{chapter}

\renewcommand*{\glslinkcheckfirsthyperhook}{%
\ifnum\glsentrycurrcount\glslabel>0
\setkeys{glslink}{hyper=false}%
\fi
}

\newabbreviation{AI}{AI}{Artificial Intelligence}
\newglossaryentry{apple}{
 type=glossary,
  name={apple},
  description={small round fruit}
}

\newglossaryentry{pear}{
 type=glossary,
  name={pear},
  description={small non-round fruit}
}

\begin{document}

\chapter{Sample}

\section{No Case Change}
\gls{AI}

Singular: \gls{apple}. Plural: \glspl{apple}.

Singular: \gls{pear}. Plural: \glspl{pear}.

\section{First Letter Uppercase}
\gls{AI}
Singular: \Gls{apple}. Plural: \Glspl{apple}.

Singular: \Gls{pear}. Plural: \Glspl{pear}.

\section{All Uppercase}
\gls{AI}
Singular: \GLS{apple}. Plural: \GLSpl{apple}.

Singular: \GLS{pear}. Plural: \GLSpl{pear}.
\newpage
\section{No Case Change}

Singular: \gls{apple}. Plural: \glspl{apple}.

Singular: \gls{pear}. Plural: \glspl{pear}.

\section{First Letter Uppercase}

Singular: \Gls{apple}. Plural: \Glspl{apple}.

Singular: \Gls{pear}. Plural: \Glspl{pear}.

\section{All Uppercase}

Singular: \GLS{apple}. Plural: \GLSpl{apple}.

Singular: \GLS{pear}. Plural: \GLSpl{pear}.
\chapter{Another Sample}

\section{No Case Change}
\gls{AI}

Singular: \gls{apple}. Plural: \glspl{apple}.

Singular: \gls{pear}. Plural: \glspl{pear}.

\section{First Letter Uppercase}

Singular: \Gls{apple}. Plural: \Glspl{apple}.

Singular: \Gls{pear}. Plural: \Glspl{pear}.

\section{All Uppercase}

Singular: \GLS{apple}. Plural: \GLSpl{apple}.

Singular: \GLS{pear}. Plural: \GLSpl{pear}.

\printglossaries

\end{document}````

相关内容