4

I am typing my thesis in LaTeX. I used hyperref. Two papers are in the bibliography. Paper no 1 is cited in the first page and paper no 2 is cited in the 2nd page.

When I am clicking the red coloured number below the paper number 1 in the bibliography it is pointing wrongly to the title page of the document. But there is NO PROBLEM with paper no 2. Please help me. I want the paper number 1 to point the correct page.

Also in my document, I don't want "Chapter 0, Synopsis". I want only "Synopsis" i.e. no mention of chapter 0 mark. This I want only for this chapter not in the later chapters. I also want synopsis to occur in the content of the document. Please help me to figure out this.

I am attaching my .tex code below.

\documentclass[12pt, reqno, a4paper]{book}

\usepackage{fancyhdr}%, setspace}

\usepackage[pagebackref]{hyperref}
\hypersetup{
     colorlinks = true, linkcolor = red,
     citecolor   = blue,
     urlcolor    = blue,
}


\begin{document}

\begin{titlepage}
\begin{center}
{\bf Title page}
\end{center} 
\end{titlepage}




\pagestyle{plain}
\pagenumbering{roman}
\addtocounter{page}{1} 

%\thispagestyle{empty}

$\textnormal{ }$
\vspace{9cm} 
\begin{center}
{\bf \Large{To my Parents}}
\end{center}


{\Large
\tableofcontents}

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark} 
\fancyhead[RE]{\bfseries\leftmark}
\lfoot{Anjan Gupta, TIFR, Mumbai.}




\pagenumbering{arabic}
\setcounter{chapter}{-1}  % to start Chapter numbers from 0

\chapter{synopsis}
\setcounter{page}{1}
In \cite[Theorem 4.1]{cr} it is shown that this is indeed true in the absolute case.

\newpage

we shall now use the result \cite{sfmaa}

\begin{thebibliography}{VAST}

\bibitem{cr} Paper 1.

\bibitem{sfmaa} Paper 2.

\end{thebibliography}

\end{document}
5
  • This is a thesis. So all the pages before chapter 0 are marked with roman numbers. From chapter 0 page numbering starts from 1. I again remind you that there is no problem with hyperref of paper 2. Jul 3, 2014 at 22:40
  • What about the \tableofcontents? Shouldn't it be the start of page 1?
    – Werner
    Jul 3, 2014 at 22:43
  • 2
    Please do not ask unrelated questions as one question. It makes it difficult for other people to find questions on topics they are searching for and to usefully assess any answers provided. Also, it means that to answer somebody needs to know both. You increase the chances of getting useful answers if you make it possible for people to fully address a single question on a single topic they are familiar with. Do you just mean \chapter*{Synopsis}\addcontentsline{toc}{chapter}{Synopsis}?
    – cfr
    Jul 3, 2014 at 23:31
  • Thank you very much. My second question is answered. It is working fine. Jul 4, 2014 at 6:15
  • Pease solve my first problem Jul 5, 2014 at 13:08

2 Answers 2

6

The chapter issue has been solved in comments, so I tried to address the duplicate page anchors.

There's another solution which should be the last resort, proposed by Werner, but he deleted his answer, so not everybody is able to see that post, so I am repeating this just for convenience and in short:

hypertexnames=false

Now, hypertexnames is often criticized, so I digged into the awesome codes of backref and hyperref.

The cause for the complaints about name(page.1) etc. is that the \pagenumbering macro resets the page number each time it \pagenumbering is called, resulting in more than one pages with the number 1, which confuses the hyperlinks. Using \clearpage statementss, this could solve the issue. If this is not done, more tricky setups have to be used.

I solved this by patching the \Hy@EveryPageAnchor command, injecting a \pagenumberingchanges macro between page and .\thepage (effectively).

\pagenumberingchanges uses \thepagenumberingcalls, which is the counter formater for pagenumberingcalls, which is stepped each time \pagenumbering is used.

In addition, this \pagenumberingchanges macro has to be written to the .brf file generated by backref each time a \cite command is applied.

This removes the multiple occurences of the same page.XYZ anchors, however, it is not failsafe, if somebody manipulates the page counter directly or with \setcounter{page}{}.

The links are alright now and point to the correct position.

Update with a version that checks whether the pagenumbering value has changed

\documentclass[12pt, a4paper]{book}

\usepackage{fancyhdr}%, setspace}

\usepackage[headheight=16pt]{geometry}% Fix the complaint of fancyhdr

\usepackage{xpatch}

\usepackage[pagebackref]{hyperref}
\hypersetup{
  colorlinks = true, linkcolor = red,
  citecolor   = blue,
  urlcolor    = blue,
}

\newcounter{pagenumberingcalls}
\newcommand{\pagenumberingchanges}{\thepagenumberingcalls}


\makeatletter

\AtBeginDocument{%

  % Each time the \pagenumbering command is called, increase a counter
  \xpretocmd{\pagenumbering}{\edef\@previouspagenumberingcalls{\thepagenumberingcalls}\stepcounter{pagenumberingcalls}}{}{}
  % Each time \cite is used, write the state of the counter to the .brf file
  \xpretocmd{\cite}{\write@to@brffile}{}{}

%Write the current pagenumbering change state to the .brf file
  % Idea from backref.sty (by David Carlisle and Sebastian Rahtz)
  \newcommand{\write@to@brffile}{%
    \edef\temp@@a{\@previouspagenumberingcalls}%
    \edef\temp@@b{\pagenumberingchanges}%
    \ifx\temp@@a\temp@@b
    \else
    \edef\@previouspagenumberingcalls{\thepagenumberingcalls}%
    \protected@write\@auxout{}{%
      \string\@writefile{brf}{%
        \string\renewcommand{\protect\pagenumberingchanges}{\thepagenumberingcalls}%
      }%
    }%  
    \fi
  }

\@ifpackageloaded{hyperref}{%
  \long\def\hyper@page@backref#1#2#3{\hyperlink{page.\pagenumberingchanges.#1}{#1}}
  \let\backrefxxx\hyper@page@backref

  \xpatchcmd{\Hy@EveryPageAnchor}{%
    \hyper@@anchor{page.\@the@H@page}%
  }{%
    \hyper@@anchor{page.\pagenumberingchanges.\@the@H@page}%
  }{\typeout{Patch 1 succeeded}}{\typeout{Patch failure for EveryPageAnchor}}
  \xpatchcmd{\Hy@EveryPageAnchor}{%
    \hyper@@anchor{page.\the\c@page}%
  }{%
    \hyper@@anchor{page.\pagenumberingchanges.\the\c@page}%
  }{\typeout{Patch 2 succeeded}}{}
  \xpatchcmd{\Hy@EveryPageAnchor}{%
    \hyper@@anchor{page.\the\Hy@pagecounter}%
  }{%
    \hyper@@anchor{page.\pagenumberingchanges.\the\Hy@pagecounter}%
  }{\typeout{Patch 3 succeeded}}{}
  }{%Nope, no hyperref loaded --> just be silent%
  }
}
\makeatother


\begin{document}
\begin{titlepage}
  \begin{center}
    \bfseries Title page
  \end{center} 
\end{titlepage}


\pagestyle{plain}
\pagenumbering{roman}
\addtocounter{page}{1}%????

{\Large
\tableofcontents}


\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark} 
\fancyhead[RE]{\bfseries\leftmark}
\lfoot{Anjan Gupta, TIFR, Mumbai.}



\pagenumbering{arabic}
\setcounter{chapter}{-1}  % to start Chapter numbers from 0

\chapter{synopsis}
In \cite[Theorem 4.1]{cr} it is shown that this is indeed true in the absolute case.

\clearpage

we shall now use the result \cite{sfmaa}

\begin{thebibliography}{VAST}
\bibitem{cr} Paper 1.

\bibitem{sfmaa} Paper 2.

\end{thebibliography}
                                %
\end{document}

Related, but different problem can be found here: https://tex.stackexchange.com/a/373678/31729

1
  • I have omitted a screen shot since it does not reveal anything new →even in the case of the wrong links the visual output provided the correct page numbers for the citations. A more elaborate strategy would check whether the expanded \pagenumberingchanges has been changed in between and writing to the .brf file would occur only if there's a real change.
    – user31729
    Feb 26, 2017 at 21:43
2

You can use \frontmatter and \mainmatter (and maybe \backmatter) to change page numbering (no need to manipulate page and chapter counters).

\documentclass[12pt, reqno, a4paper]{book}

\usepackage{fancyhdr}%, setspace}

\usepackage[pagebackref]{hyperref}
\hypersetup{
     colorlinks = true, linkcolor = red,
     citecolor   = blue,
     urlcolor    = blue,
}

\begin{document}
\frontmatter

\begin{titlepage}
  \begin{center}
    {\bf Title page}
  \end{center} 
\end{titlepage}

\pagestyle{plain}

%\thispagestyle{empty}

$\textnormal{ }$
\vspace{9cm} 
\begin{center}
{\bf \Large{To my Parents}}
\end{center}


{\Large
\tableofcontents}

\mainmatter

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark} 
\fancyhead[RE]{\bfseries\leftmark}
\lfoot{Anjan Gupta, TIFR, Mumbai.}



\chapter*{synopsis}
\addcontentsline{toc}{chapter}{Synopsis}
In \cite[Theorem 4.1]{cr} it is shown that this is indeed true in the absolute case.

\newpage

we shall now use the result \cite{sfmaa}

\begin{thebibliography}{VAST}

\bibitem{cr} Paper 1.

\bibitem{sfmaa} Paper 2.

\end{thebibliography}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .