7

I tried to produce a ToC like this:

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

So I added the listof's, glossaries and bibliography to the ToC with success. But now the ToC links went out of sync. Also the links in the listof's do not match any longer. Heres a mwe (without bibliography)

\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}

I compile the PDF this way:

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

What went wrong here? (I tried even to put \cleardoublepage\phantomsection almost everywhere in different positions so far)


EDIT #1:

I stripped the guts out to a minimal mwe, where the back links in the glossaries are still wrong:

\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}

EDIT #2:

I'd like to share my compilation-batch file (I couldn't find a good one in the 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
  • Why do you have \cleardoublepage\phantomsection before \printglossary? The toc package option does \phantomsection automatically at the start of each glossary (and \cleardoublepage is automatically inserted regardless of the toc option for book-like classes). – Nicola Talbot Sep 25 '14 at 14:38
  • Thank you, I did not know that, I removed it from this example, but still, the back-link in the glossaries refer to the wrong pages – nonsensation Sep 25 '14 at 14:50
  • I could not decide which answer to choose as the answer, both of them solved my problem in combination. Thanks to you two! – nonsensation Sep 26 '14 at 9:30
5

The insertion of the glossaries and other lists cause the page numbers to change so you need to do:

pdflatex
makeglossaries
pdflatex
makeglossaries
pdflatex

to get them up-to-date.

The first makeglossaries generates the glossaries but uses the page numbers from the first LaTeX run, so you need another LaTeX run to update the page numbers, then rerun makeglossaries to update the back-references and rerun LaTeX to update the document.

5

You get messages saying something like

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

which shouldn't be ignored. They are caused by having chapters with the same number.

You can solve it by adding

\renewcommand\theHchapter{\thechapter}

after doing \renewcommand{\thechapter}{\Roman{chapter}}. In this way hyperref will use a unique internal identifier for chapters and return in sync.

  • Thank you! The links in the ToC are now working! However the backlinks from the glossaries to its first use are still out of sync – nonsensation Sep 25 '14 at 10:58
  • There's no \gls in your sample. If I add \gls{bla2}, then the link in the glossary points to it. – egreg Sep 25 '14 at 11:01
  • Huh? Isn't there a \gls{bla1} blablabla \gls{bla2} right in the middle? – nonsensation Sep 25 '14 at 11:05
  • Do I have to add the \renewcommand\theHchapter{\thechapter} after every \renewcommand{\thechapter}{...} entry? Or only after this specific one with Roman? – nonsensation Sep 25 '14 at 11:13
  • Oh it should mean renewcommand instead of renewcomand (one m is missing) – nonsensation Sep 25 '14 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.