LaTeX 術語表參考問題

LaTeX 術語表參考問題

在我的碩士論文中,我使用詞彙表包來追蹤所有縮寫和符號。為了區分兩者,我製作了兩個不同的術語表。一欄使用標準縮寫包,一欄是我自己定義的符號列表(我使用自己的樣式,因為我需要四列,一列用於符號,一列用於單位,一列用於描述,一列用於頁面)。

我還使用羅馬和阿拉伯編號。當我單擊(符號)術語表中的引用時,它會正確地重定向到文字中的位置。但是,當我單擊文字中的(符號)引用時,它會重定向到第一頁(而不是符號列表中的正確位置)。

但是,對於縮寫列表,它確實可以正常工作。錯誤一定出在我的新樣式的定義。即使您刪除編號更改,它仍然會重定向到第一頁。

hyperrefname似乎沒有解決問題。我該如何修復它?

我包括了一個最小工作範例(MWE),您可以使用所有套件和 Perl 編譯器來執行。

\documentclass[a4paper]{book}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=Maroon, citecolor=ForestGreen, filecolor=magenta, urlcolor=magenta, hypertexnames=false}

%% Glossary properties
\usepackage[nomain,acronym,toc,section]{glossaries}
\newglossary{symbol}{sbl}{smb}{Symbols}
\usepackage{array}
\makeglossaries
\usepackage[xindy]{imakeidx}
\makeindex

%% My own glossary to display the units
\newglossarystyle{tabx4col}{%
% Put the glossary in a longtable environment:
\renewenvironment{theglossary}%
{\begin{longtable}{@{}p{0.12\textwidth}@{}p{0.12\textwidth}@{}p{0.56\textwidth}rp{0.15\textwidth}}}%
{\end{longtable}}%
\renewcommand*{\glossaryentryfield}[5]{%
\glstarget{\textbf{##1}}{\textbf{##2}}% Name
 & $[$\glsentryuseri{##1}$]$% Units
 & ##3% Description
 & ##5% Page list
        \\% end of row
}%
%% Nothing between groups:
\renewcommand*{\glsgroupskip}{}%
}

%% Abbreviations
\newacronym{abr1}{ABR1}{Abbreviation 1}
\newacronym{abr2}{ABR2}{Abbreviation 2}

%% Symbols
\newglossaryentry{sym1}
{%
  type=symbol,
  name={\ensuremath{\alpha}},
  description={The first symbol, with a very long description that spans multiple lines},
  user1={kg},
  sort=alpha
}
\newglossaryentry{sym2}
{%
  type=symbol,
  name={\ensuremath{\beta}},
  description={the second symbol},
  user1={m},
  sort=beta
}

\begin{document}
\pagenumbering{roman}
\tableofcontents
{\let\cleardoublepage\clearpage
    \chapter*{List of abbreviations and symbols}
    \addcontentsline{toc}{chapter}{List of abbreviations and Symbols}
    \printglossary[type=\acronymtype,title=Abbreviations,toctitle=Abbreviations]
    \printglossary[type=symbol,style=tabx4col]
}
\chapter{Introduction}
\pagenumbering{arabic}
\gls{abr1} \gls{abr2} \gls{sym1} \gls{sym2}
\chapter{First chapter}
\gls{abr1} \gls{abr2} \gls{sym1} \gls{sym2}
\end{document}

答案1

測試檔案會產生多個警告hyperref

pdfTeX warning (dest): name{glo:sym1} has been referenced but does not exist, 
replaced by a fixed one

這有點神秘,但這可能意味著超連結目標機制glossaries出了問題。glossaries由於此連結不存在,導致超連結將您帶到文件的第一頁。此命令\glstarget以術語表樣式設定此超連結。第一個參數必須是條目的標籤,問題如下:

\glstarget{\textbf{##1}}{\textbf{##2}}% Name

\textbf一個參數混淆了目標機制。您只需將其刪除即可解決問題:

\glstarget{##1}{\textbf{##2}}% Name

相關內容