3

Problem description:

  1. I cite the same references multiple times;
  2. each time they are cited, different page numbers are provided;
  3. the page numbers are being shown together with the citation, on the article text body;
  4. I'm being required to somehow make them appear not on the article text body, but instead on the references section.

What I'm doing (code):

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \cite[pages 4 and 5]{Fonseca2020} \cite[page 16]{Silva2006}. Ut enim ad minim veniam, \cite[page 40]{Moreira2010} quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \cite[pages 136 to 138]{Freitas2019} Excepteur sint occaecat cupidatat non proident, \cite[page 10]{Cunha2019} sunt in culpa qui officia deserunt mollit anim id est laborum.

What I'm getting:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. [1, pages 4 and 5] [2, page 16]. Ut enim ad minim veniam, [3, page 40] quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. [4, pages 136 to 138] Excepteur sint occaecat cupidatat non proident, [5, page 10] sunt in culpa qui officia deserunt mollit anim id est laborum.

References:

  1. Fonseca. "Title". (2020).
  2. Silva. "Title". (2006).
  3. Moreira. "Title". (2010).
  4. Freitas. "Title". (2019).
  5. Cunha. "Title". (2019).

What I need to get instead, somehow:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. [1a] [2a]. Ut enim ad minim veniam, [3a] quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. [4a] Excepteur sint occaecat cupidatat non proident, [5a] sunt in culpa qui officia deserunt mollit anim id est laborum.

References:

  1. Fonseca. "Title". (2020). a: pages 4 and 5, b: ..., c: ...
  2. Silva. "Title". (2006). a: page 16, b: ..., c: ...
  3. Moreira. "Title". (2010). a: page 40, b: ..., c: ...
  4. Freitas. "Title". (2019). a: pages 136 to 138, b: ..., c: ...
  5. Cunha. "Title". (2019). a: page 10, b: ..., c: ...

Question: how do I get the expected result exemplified above?

Same question as:

  1. 2012 - Bibtex references, citing from same reference but different page
  2. 2014 - Citing multiple chapters in the same book under the same reference number

The above pointed questions did not receive adequate answers that solves my problem.

6
  • 3
    well I would ask the people who require that from you how to do it. Apart from this, here is some code to collect the postnotes: tex.stackexchange.com/a/636374/2388. Commented Jul 8 at 14:21
  • 1
    Do you also want "a" to appear if you cite the work only once? Do you want the same letter to be reused if you cite the exact same postnote again? This whole thing seems complex, but doable. How complex also depends on the answer to those questions.
    – moewe
    Commented Jul 8 at 14:27
  • @UlrikeFischer I'm sure that the requiring people don't know how to do it. Or I find a way to do it or I will need to get rid of the page numbers, which I really don't want to happen. Commented Jul 8 at 14:28
  • 2
    well people shouldn't require things that they can't do themselve. Commented Jul 8 at 14:30
  • @moewe The answer to both questions is that both options seems to be equally acceptable to me. I just need to save the page numbers from being deleted. I did not receive specific instructions on how the citations should behave after the edit, I was just instructed to move them to the references section. Commented Jul 8 at 14:33

1 Answer 1

4

Combining ideas from Customize backref similar to Wikipedia and Citation Page Numbers in Bibliography I'd like to suggest

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{hyperref}

\usepackage[style=numeric, backend=biber]{biblatex}

\renewbibmacro{postnote}{}

\makeatletter
\DeclareFieldFormat{bibhypertarget}{%
  \bibhypertarget{cbx:instcount:\the\value{instcount}}{#1}}

\def\abx@aux@pnbackref#1#2#3#4{%
  \listcsgadd{cbx@pnbackref@#1@#2}{#3}%
  \csgdef{cbx@pnbackref@postnote@#1@#2@#3}{#4}}

\def\blx@addpnbackref#1#2{%
  \if@filesw
    \protected@write\@mainaux{}{%
      \string\abx@aux@pnbackref
        {\the\c@refsection}{#1}{\the\value{instcount}}
        {\detokenize{#2}}}%
    \fi}

\def\blx@addpnbackref@helper#1{\blx@addpnbackref{\thefield{entrykey}}{#1}}

\def\blx@instcount@label{%
  \label{cbx@instcount@\the\value{instcount}}}

\AtEveryCitekey{%
  \iffieldundef{postnote}
    {}
    {\expandafter\blx@addpnbackref@helper\expandafter{\abx@field@postnote}%
     \ifcsundef{cbx@pnbackref@count@\the\c@refsection @\abx@field@entrykey}
       {\csgdef{cbx@pnbackref@count@\the\c@refsection @\abx@field@entrykey}{1}}
       {\csnumgdef{cbx@pnbackref@count@\the\c@refsection @\abx@field@entrykey}{%
          \csuse{cbx@pnbackref@count@\the\c@refsection @\abx@field@entrykey}+1}}}%
  \blx@instcount@label
}

\newcommand*{\pnbackref@prnt@pn}[2]{%
  \DeclareFieldFormat{bibhypertarget}{\bibhyperlink{cbx:instcount:#2}{##1}}%
  \printtext[bibhypertarget]{%
    \printtext{\alph{backrefitemcount}}%
    \setunit{\addcolon\space}%
    \printtext[postnote]{#1}}}

\newbibmacro*{pnbackref:item}[1]{%
  \ifcsvoid{cbx@pnbackref@postnote@\the\c@refsection @\thefield{entrykey}@#1}
    {}
    {\stepcounter{backrefitemcount}%
     \letcs\cbx@tempa{cbx@pnbackref@postnote@\the\c@refsection @\thefield{entrykey}@#1}%
     \expandafter\pnbackref@prnt@pn\expandafter{\cbx@tempa}{#1}%
     \setunit{\addcomma\space}}}

\newcounter{backrefitemcount}
\newbibmacro*{pnbackref}{%
  \ifcsundef{cbx@pnbackref@\the\c@refsection @\thefield{entrykey}}
    {}
    {\setcounter{backrefitemcount}{0}%
     \forlistcsloop{\usebibmacro{pnbackref:item}}
       {cbx@pnbackref@\the\c@refsection @\thefield{entrykey}}}}

\renewbibmacro*{pageref}{\usebibmacro{pnbackref}}


\renewcommand*{\bibpagerefpunct}{\addperiod\space}

\renewbibmacro*{cite}{%
  \printtext[bibhypertarget]{%
    \printtext[bibhyperref]{%
      \printfield{labelprefix}%
      \printfield{labelnumber}%
      \ifbool{bbx:subentry}
        {\printfield{entrysetcount}}
        {}%
      \iffieldundef{postnote}
        {}
        {\printtext{%
           \mknumalph{%
             \csuse{cbx@pnbackref@count@\the\c@refsection @\abx@field@entrykey}}}}}}}
\makeatother

\addbibresource{biblatex-examples.bib}


\begin{document}
Lorem~\autocite[380]{sigfridsson}
ipsum~\autocite[12-14]{worman}
dolor~\autocite{nussbaum}
sit~\autocite[381]{sigfridsson}
amet~\autocite[382]{sigfridsson}.

\clearpage

Lorem~\autocite[27-30]{geer}
ipsum~\autocite[\textbf{ä}]{worman}
dolor~\autocite[34]{pines}
sit~\autocite[382]{sigfridsson}
amet~\autocite[383]{sigfridsson}.

Dolor~\autocite[380-381]{worman}

\printbibliography
\end{document}

Citations with letters and page numbers.

The code will require sufficient LaTeX reruns since the postnote is passed through the .aux file. (But I didn't build in any additional tests to check if a rerun is necessary, so you will have to make sure to run LaTeX the appropriate number of times after you change anything about the citations.)

You must log in to answer this question.

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