0

I am writing a document in which I will input the PDF of some of my papers. In the introduction, I would like to refer to them in this way

(Joce et al, 2019, included page XX).

I can of course do this by defining a specific cite call for those papers:

\newcommand{\citeinc}[1]{\cite[][included page \pageref{ref:#1}]{#1}}

but this requires to use a different cite command for my papers and those of others, meaning I need to check that I always do so in text I reuse from previous documents, and more importantly that I can't do such things e.g.

\cite{Other12,Joce13,YAOne14}

(Other et al, 2012, Joce et al, 2013, included page 101, One et al., 2014)

Given the high level of customization offered by biber, I wonder whether it would be possible to auto-append this text to my reference label (but it shoudn't show in the reference list, although... that'd be acceptable I guess).

4
  • Can you share some more details about your setup? Should all other entries also be cited in author-year style (so that the only difference between a normal entry and your papers is that instead of "Smith" - assuming that is your family name - we have "me")?
    – moewe
    Mar 6, 2020 at 20:47
  • Possibly related: tex.stackexchange.com/q/519654/35864
    – moewe
    Mar 6, 2020 at 20:47
  • @moewe: Thanks for your comment, actually the question must be unclear since what I want is not replacement of the name, I'm rephrasing now.
    – Joce
    Mar 9, 2020 at 17:37
  • @moewe: the solution in the link you point is maybe possible to adapt to this case? Can one redefine the printing of the date e.g., and could one include a \pageref call within it? And optionally, print this added text only in labels, not in ref list.
    – Joce
    Mar 9, 2020 at 19:38

1 Answer 1

1

Assuming that you \label all your included papers with \label{ref:<entrykey>} and do not use this label format anywhere else, you can use the following approach.

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

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

\NewBibliographyString{included}

\DefineBibliographyStrings{english}{
  included = {included on},
}

\newbibmacro{ref:inclusion}{%
  \ifcsundef{r@ref:\strfield{entrykey}}
    {}
    {\bibstring{included}%
     \setunit{\addspace}%
     \printtext{\pno~\pageref{ref:\strfield{entrykey}}}}}

\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\printdelim{nonameyeardelim}}}
       {\printnames{labelname}%
        \setunit{\printdelim{nameyeardelim}}}%
     \usebibmacro{cite:labeldate+extradate}}
    {\usebibmacro{cite:shorthand}}%
  \setunit{\addcomma\space}%
  \usebibmacro{ref:inclusion}}

\renewbibmacro*{textcite}{%
  \ifnameundef{labelname}
    {\iffieldundef{shorthand}
       {\usebibmacro{cite:label}%
        \setunit{%
          \global\booltrue{cbx:parens}%
          \printdelim{nonameyeardelim}\bibopenparen}%
        \ifnumequal{\value{citecount}}{1}
          {\usebibmacro{prenote}}
          {}%
        \usebibmacro{cite:labeldate+extradate}%
        \setunit{\addcomma\space}%
        \usebibmacro{ref:inclusion}}
       {\usebibmacro{cite:shorthand}%
        \setunit{%
          \global\booltrue{cbx:parens}%
          \printdelim{nonameyeardelim}\bibopenparen}%
        \ifnumequal{\value{citecount}}{1}
          {\usebibmacro{prenote}}
          {}%
        \usebibmacro{ref:inclusion}}}
    {\printnames{labelname}%
     \setunit{%
       \global\booltrue{cbx:parens}%
       \printdelim{nameyeardelim}\bibopenparen}%
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \usebibmacro{citeyear}%
     \setunit{\addcomma\space}%
     \usebibmacro{ref:inclusion}}}

\addbibresource{biblatex-examples.bib}


\begin{document}
\section{Some text}
\cite{sigfridsson,worman,geer}

\cite{sigfridsson}

\cite{nussbaum}

\printbibliography

\section{\texttt{sigfridsson}}\label{ref:sigfridsson}
Here is \texttt{sigfridsson}

\section{\texttt{nussbaum}}\label{ref:nussbaum}
Here is \texttt{nussbaum}
\end{document}

Sigfridsson and Ryde 1998, included on p. 1; Worman 2002; Geer 1985//Sigfridsson and Ryde 1998, included on p. 1//Nussbaum 1978, included on p. 1

Here, the bibmacro ref:inclusion uses the fact that \label{foo} defines the command r@foo, so we can easily check if there is a label for the current entry key. If such a label exists, we assume it is one for inclusion of the whole paper and link to it.

The rest of the code just consists of adding the new macro ref:inclusion to cite and textcite in the right places.

The MWE does not add a note to the bibliography about the inclusion. If you want that, you could add something like

\renewbibmacro*{finentry}{\newunit\usebibmacro{ref:inclusion}\finentry}
1
  • That's perfect, thanks a lot.
    – Joce
    Mar 9, 2020 at 20:40

You must log in to answer this question.

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