2

I am writing lecture notes where the title page numbering is set to gobble, the toc pages are in roman and the lectures pages are in arabic.

The problem is specifically on the 1st lecture page. I have a citation on the page. But its bib item on the bibliography section is back-referencing to the title page. The other citations that are not on the 1st page are not having this issue.

Here's the MWE of my lecture notes:

\documentclass[a4paper]{report}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \input{setup/preamble} % basics \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{textcomp} \usepackage{url} \usepackage{hyperref} \hypersetup{ colorlinks, linkcolor={black}, citecolor={black}, urlcolor={blue!80!black}, % backref=true, % pagebackref=true }

% Page Margins \usepackage[ margin=2.8cm, % top=2.8cm, bottom=2.8cm, % left=1in, right=1in, % headheight=14.5pt ]{geometry}

% \usepackage{graphicx} % \usepackage{float} \usepackage[usenames,dvipsnames]{xcolor} \usepackage{lipsum}

% bibliography \usepackage[ backend=biber, backref=true, style=numeric, sortcites=true, sorting=none, defernumbers=true ]{biblatex} % bibliography % https://www.overleaf.com/learn/latex/bibliography_management_with_biblatex \usepackage{xurl} % handling the urls in bib file and it should be loaded after loading biblatex

%% Change formatting of back references % https://tex.stackexchange.com/a/606518/114006 \DefineBibliographyStrings{english}{ backrefpage={p.}, % backrefpage={}, backrefpages={pp.} % backrefpages={ } \renewcommand*{\finentrypunct}{} \usepackage{xpatch}

% \DeclareFieldFormat{backrefparens}{\mkbibparens{#1\addperiod}} \DeclareFieldFormat{backrefparens}{\raisebox{-4pt}{\scriptsize{\mkbibparens{#1}}}} \xpatchbibmacro{pageref}{parens}{backrefparens}{}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{filecontents}{ref.bib} @book{arnold2013mathematical, title = {Mathematical {{Methods}} of {{Classical Mechanics}}}, author = {Arnold, Vladimir I}, date = {2013}, series = {Graduate {{Texts}} in {{Mathematics}}}, volume = {60}, publisher = {{Springer Science & Business Media}} } @article{yang1954conservation, title = {Conservation of {{Isotopic Spin}} and {{Isotopic Gauge Invariance}}}, author = {Yang, Chen N and Mills, Robert L}, date = {1954-10-01}, journaltitle = {Physical Review}, shortjournal = {Phys. Rev.}, volume = {96}, number = {1}, pages = {191--195}, doi = {10.1103/PhysRev.96.191} } \end{filecontents}

\addbibresource{ref.bib}

\title{Lecture Notes} \author{me}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\maketitle \pagenumbering{gobble} % \input{preface} \newpage \pagenumbering{roman} \pdfbookmark{\contentsname}{toc}
\setcounter{tocdepth}{0} \tableofcontents \newpage \pagenumbering{arabic}

% start lectures \chapter{Sat, Mar 18, 2023}

\lipsum[1] \cite{arnold2013mathematical} \lipsum \cite{yang1954conservation}

% \intput{endpage}

% Bibliography \printbibheading[heading=bibintoc, title={\protect\numberline{}Recommended Resources}] % https://tex.stackexchange.com/a/222961/114006 \printbibliography[type=book,heading=subbibliography,title={Books}] % https://www.overleaf.com/learn/latex/Articles/Getting_started_with_BibLaTeX \printbibliography[nottype=book,heading=subbibliography,title={Others}]

\end{document}

raf
  • 633
  • Probably unrelated but you should load hyperref last, it can cause strange issues when it isn't. Put it last out of the packages and see if your issue persists – JamesT Jul 03 '23 at 13:04
  • @JamesT I have just tried it but nothing changed. – raf Jul 03 '23 at 13:15
  • 2
    \pagenumbering{gobble} looks like a neat trick to get an empty page style but with hyperref it is bad as you still have two pages with number one. Either ensure that you have different page numbers everywhere or supress anchors on the the title page with the NoHyper environment. – Ulrike Fischer Jul 03 '23 at 14:26
  • @UlrikeFischer, how can I ensure different page numbers everywhere keeping in mind that the titlepage and preface should not display any page number?

    I tried using NoHyper environment and it fixed the issue on this MWE. But it's not suitable for my main document (https://github.com/rafisics/lecture-notes-template) because it has hyperlinks in titlepage/preface.

    – raf Jul 03 '23 at 15:15
  • https://tex.stackexchange.com/q/690327/114006 – raf Jul 05 '23 at 08:19

1 Answers1

2

This is probably a hack (and Ulrike will scold me for that ) but if you remove the \pagenumbering{gobble} and add, before \maketitle:

\pagenumbering{roman}
\setcounter{page}{-1}\thispagestyle{empty}
\maketile
[...]

(and obviously remove the other \pagenumbering{roman} below) the backlink of the bibliography seems to work.

I didn't try your full example (this one is already on the big side for an MWE...), but probably the only trick is to find the correct negative number to start with...

The other option, as suggested by Ulrike in a comment, is to change the "name" of the page; something on the line of changing the title part like that:

% make a full copy of the current \thepage
\NewCommandCopy{\savethepage}{\thepage}
\pagenumbering{gobble}
\renewcommand{\thepage}{Title-Preface-\arabic{page}}
\maketitle
% \input{preface}
\newpage
% reset back the page name
\RenewCommandCopy{\thepage}{\savethepage}
\pagenumbering{roman}

...so you should have different anchor names even if there are more than one title-preface unnumbered pages.

Using the full expl3 copies is probably too much, and a \let should suffice in this case. But you never know if \thepage will change in the future...

Or even easier, as suggested again by Ulrike (thanks!)

\pagenumbering{gobble}
% this is reset back by \pagenumbering
\gdef\thepage{Title-Preface-\arabic{page}}
\maketitle
% \input{preface}
\newpage
% \pagestyle{plain}
\pagenumbering{roman}
Rmano
  • 40,848
  • 3
  • 64
  • 125
  • 2
    setting the page number of the title page to zero is actually one sensible option, see https://github.com/latex3/latex2e/issues/647. But e.g. \renewcommand\thepage{Title}\maketitle would work too. It only matters that the page has a different "name" as the other pages. – Ulrike Fischer Jul 04 '23 at 18:05
  • Thank you. Can you please help me with the last part of my question too? While asking, I didn't know it's related to the page numbering. I thought it's a bibliography issue and that's why I included it in the same question. – raf Jul 05 '23 at 00:48
  • 1
    @raf Please ask separate questions for separate issues. You can still edit out the second issue and re-ask it as a question on its own. – moewe Jul 05 '23 at 06:03
  • 1
    Yes, please do as @moewe says: I am not very good with bibliographies, so I can't really help there. This is the reason why the site polices are "just one question"... – Rmano Jul 05 '23 at 06:16
  • Thank you. I have moved the separate issue regarding back-referencing to this new question here: https://tex.stackexchange.com/q/690327/114006 – raf Jul 05 '23 at 08:22
  • @Rmano, actually I think Ulrike's suggestion of using \renewcommand\thepage{Title} would be preferable to me. What's your thought about it? Can there appear any complication in choosing his method? :) – raf Jul 05 '23 at 09:15
  • I added an implementation of @UlrikeFischer suggestion. I think it will work correctly even if you have several unnumbered pages for the preface and even with links on it (although they will be funny, I think). – Rmano Jul 05 '23 at 09:29
  • 2
    you don't need to reset the \thepage definition, \pagenumbering contains \gdef\thepage{...} (which probably means \gdef\thepage{Title} would be a bit more consistent ..) – Ulrike Fischer Jul 05 '23 at 09:44
  • By the way, it's generally recommended to use the roman page-numbering right after the title page in academia, right? – raf Jul 05 '23 at 09:59
  • @raf, in my experience, "generally" and "in academia" are basically an oxymoron. You'll find zillions of (often silly) local conventions. – Rmano Jul 05 '23 at 10:12
  • I see. Basically, I asked about the most accepted or standard convention for academic documents. :) – raf Jul 05 '23 at 11:04