Hyperref:目录中的 listof、参考书目和词汇表链接错误

Hyperref:目录中的 listof、参考书目和词汇表链接错误

我尝试制作如下目录:

I    Symbol Glossary
II   Acronyms
1.   Chapter 1
     1.1 Section 1
2.   Chapter 2...
...
III  List of Figures
IV   List of Tables
V    Bibliography

所以我成功地将和添加到了listof目录中。但现在目录链接不同步了。而且 中的链接也不再匹配。这是一个 mwe(没有参考书目)glossariesbibliographylistof

\RequirePackage[l2tabu,orthodox]{nag}

\documentclass
[
    pdftex ,
    a4paper ,
    oneside ,
    12pt ,
    halfparskip ,
    headsepline ,
    footsepline ,
    listof=totocnumbered ,
    bibliography=totocnumbered ,
    numbers=noenddot ,
]{scrbook}

\usepackage[]{amsmath,amssymb}
\usepackage[]{graphicx}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[]{color}

\usepackage
[
    a4paper ,
    top=3.6cm ,
    bottom=3.6cm ,
    left=3.6cm ,
    right=3.6cm ,
]{geometry}

\usepackage[]{microtype}
\usepackage{setspace}
\usepackage[]{ftnxtra}
\usepackage{hyperref}

\usepackage
[
    nomain ,
    toc ,
    indexonlyfirst ,
    numberedsection ,
]{glossaries}

\usepackage
[
    block=par ,
    backend=biber ,
    safeinputenc ,
    backref ,
]{biblatex}

\onehalfspacing

\KOMAoptions{draft=on}

\setlength\parindent{0pt}

\definecolor{blue}{rgb}{ 0.0 , 0.0 , 1.0 }

\hypersetup
{
    colorlinks          = true ,
    linkcolor           = blue ,
    citecolor           = blue ,
    filecolor           = blue ,
    menucolor           = blue ,
    urlcolor            = blue ,
    bookmarksnumbered   = true ,
}

\newglossary[sym.glg]{sym}{sym.gls}{sym.glo}{Symbolverzeichnis}
\newglossary[acr.glg]{acr}{acr.gls}{acr.glo}{Abkürzungsverzeichnis}

\makeglossaries

\newglossaryentry{bla2}
{
    text        = {bla2} ,
    name        = {bla2} ,
    plural      = {bla2} ,
    description = {bla2bla2bla2bla2bla2} ,
    type        = {acr} ,
    sort        = {bla2} ,
}

\newglossaryentry{bla1}
{
    text        = {bla1} ,
    name        = {bla1} ,
    plural      = {bla1} ,
    description = {bla1bla1bla1bla1bla1} ,
    type        = {sym} ,
    sort        = {bla1} ,
}

% \addbibresource{eli_bib.bib}

\title{\textbf{Title}}

\begin{document}

\pagenumbering{arabic}

\maketitle

\thispagestyle{empty}

\renewcommand{\contentsname}{Inhaltsverzeichnis}
\renewcommand\thechapter{\Roman{chapter}}

\cleardoublepage\phantomsection
\tableofcontents

\cleardoublepage\phantomsection
\printglossary[type=acr,title=Abkürzungsverzeichnis]

\cleardoublepage\phantomsection
\printglossary[type=sym,title=Symbolverzeichnis]

\renewcommand\thechapter{\arabic{chapter}}
\setcounter{chapter}{0}


\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}

\gls{bla1} blablabla \gls{bla2}

\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}
\chapter{test}\section{test}


\renewcommand\thechapter{\Roman{chapter}}
\setcounter{chapter}{3}
\cleardoublepage\phantomsection
\listoftables
\cleardoublepage\phantomsection
\listoffigures
\cleardoublepage\phantomsection
\printbibliography[title=Literaturverzeichnis]

\end{document}

我是这样编译 PDF 的:

pdflatex -interaction=batchmode -draftmode %doc%.tex
makeindex -s %doc%.ist -t %doc%.sym.glg -o %doc%.sym.gls %doc%.sym.glo
makeindex -s %doc%.ist -t %doc%.acr.glg -o %doc%.acr.gls %doc%.acr.glo
biber %doc%
pdflatex -interaction=batchmode -draftmode %doc%.tex
pdflatex -interaction=batchmode -synctex=1 %doc%.tex

\cleardoublepage\phantomsection这里出了什么问题?(到目前为止,我甚至尝试将几乎所有地方都放在不同的位置)


编辑#1:

我把核心部分剥离到最小的 mwe,但词汇表中的反向链接仍然是错误的:

\documentclass[oneside]{scrbook}
\usepackage[ngerman]{babel}
\usepackage{color,hyperref}
\usepackage[nomain]{glossaries}

\newglossary[sym.glg]{sym}{sym.gls}{sym.glo}{Symbolverzeichnis}
\newglossary[acr.glg]{acr}{acr.gls}{acr.glo}{Abkürzungsverzeichnis}
\makeglossaries
\newglossaryentry{bla2}{name={bla2},description={bla2bla2bla2bla2bla2},type={acr}}
\newglossaryentry{bla1}{name={bla1},description={bla1bla1bla1bla1bla1},type={sym}}

\begin{document}

\printglossary[type=acr]\printglossary[type=sym]

\chapter{test}\section{test}\chapter{test}\section{test}
\gls{bla1} blablabla \gls{bla2}
\chapter{test}\section{test}\chapter{test}\section{test}

\end{document}

编辑#2:

我想分享我的编译批处理文件(我在 www 上找不到好的文件):

GitHub-Gist

:: sumatrapdf.exe is in miktex/miktex/bin
:: biber.exe in miktex/miktex/bin
:: sumatrapdf: einstellungen > optionen : 'pfad/zu/sublime_text.exe %f:%l:100000' eintragen
:: call this batch file like: 'tex.bat myTexFile' (myTexFile without any extension)

@echo off

setlocal

set document=%~n1
set miktexpath=C:/bin/programme/miktex/miktex/bin

set path=%path%;%miktexpath%;

call :deletetemporaries
call :compile

goto final

:compile
    echo ! Begin Compilation
    call :buildtex

    if errorlevel 1 (
        call :syntaxerror
    ) else (
        call :buildglossaries
        call :buildbib
        call :buildtex
        call :buildglossaries
        call :buildpdf
        call :showpdf
        call :deletetemporaries
    )

:deletetemporaries
    echo ! Delete temporaries
    del /s *glg >nul 2>&1
    del /s *gls >nul 2>&1
    del /s *glo >nul 2>&1
    del /s *blg >nul 2>&1
    del /s *bbl >nul 2>&1
    del /s *toc >nul 2>&1
    del /s *out >nul 2>&1
    del /s *log >nul 2>&1
    del /s *lot >nul 2>&1
    del /s *lof >nul 2>&1
    del /s *ist >nul 2>&1
    del /s *bcf >nul 2>&1
    del /s *aux >nul 2>&1
    del /s *run.xml >nul 2>&1
goto end


:buildglossaries
    makeindex -s %document%.ist -t %document%.sym.glg -o %document%.sym.gls %document%.sym.glo 2>nul
    makeindex -s %document%.ist -t %document%.acr.glg -o %document%.acr.gls %document%.acr.glo 2>nul
    makeindex -s %document%.ist -t %document%.idx.glg -o %document%.idx.gls %document%.idx.glo 2>nul
goto end

:buildpdf
    pdflatex -interaction=batchmode -synctex=1 %document%.tex 1>nul
    echo.
goto end

:buildtex
    pdflatex -interaction=batchmode -draftmode %document%.tex 1>nul
goto end

:buildbib
    biber %document% 2>nul
goto end

:syntaxerror
    pdflatex -draftmode %document%.tex
    echo ! Compilation failed
goto end

:showpdf
    SumatraPDF -reuse-instance %document%.pdf 1>nul
goto end

:final
    echo ! Compile done
    echo.
    exit

:end
    goto:eof

答案1

插入词汇表和其他列表会导致页码发生变化,因此您需要执行以下操作:

pdflatex
makeglossaries
pdflatex
makeglossaries
pdflatex

以使它们保持最新状态。

第一个makeglossaries生成词汇表,但使用第一次运行 LaTeX 的页码,因此您需要另一次运行 LaTeX 来更新页码,然后重新运行makeglossaries以更新反向引用并重新运行 LaTeX 来更新文档。

答案2

您会收到类似以下消息

pdfTeX warning (ext4): destination with the same identifier (name{chapter.4
}) has been already used, duplicate ignored

不应忽略。它们是由具有相同编号的章节引起的。

您可以通过添加来解决

\renewcommand\theHchapter{\thechapter}

完成后\renewcommand{\thechapter}{\Roman{chapter}}。这样hyperref将使用章节的唯一内部标识符并同步返回。

相关内容