3

Is it possible to reference to a citation inside a refsection from the outside? And I mean outside not as in "inside another refsection", but as in "inside no refsection".

In the following MWE, the label of ArticleA is properly printed, but the link does not lead to the list of references in SectionB.

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{MWE.bib}
@article{articleA,
author = {Clark Kent},
title  = {On why superman is stronger than batman},
journal = {The daily planet},
year   = {2016},
}
@article{articleB,
author = {Bruce Wayne},
title  = {On why batman is stronger than superman},
journal = {Wayne Enterprises journal},
year   = {2016},
keywords = {blablabla},
}
\end{filecontents}
\usepackage[backend=biber,style=alphabetic]{biblatex}
\addbibresource{MWE.bib}
\usepackage[colorlinks]{hyperref}
\hypersetup{urlcolor=blue, citecolor=blue, linkcolor=blue}

\begin{document}

\section{Section Title A}
This is outside any refsection.
Here's a normal reference: \cite{articleB}. 
Here's a reference that's only listed inside a refsection: \cite{articleA}
\printbibliography[keyword=blablabla]

\newpage
\begin{refsection}
\section{Section Title B}
\cite{articleA}, \cite{articleB}
\printbibliography
\end{refsection}

\end{document}
jpb
  • 501
  • 1
    Since refsections are by construction kept local I don't think this can work. If you are not inside any refsection you are actually inside the default section 0. Do you really need refsections, could you maybe use refsegments which are not as reclusive? – moewe Apr 10 '16 at 10:56
  • Oh, I did not know about refgments, thank you for the suggestion! – jpb Apr 10 '16 at 10:58
  • 1
    Let me know if it worked for you. And if not you might want to specify what your actual use case is, maybe we can cook something up for that too. – moewe Apr 10 '16 at 11:01
  • It works in my MWE like a charm, can you write your suggestion as an answer so I can mark my question as answered? – jpb Apr 10 '16 at 11:02
  • 2
    @moewe: I had to do something similar for some one: They wanted three (!) independant bibliographies with overlapping entries could be cited everywhere in the document. I implemented it by splitting the refsections in small parts: https://github.com/plk/biblatex/issues/307. – Ulrike Fischer Apr 10 '16 at 11:09

1 Answers1

2

You probably want to use refsegments instead of refsections. Since the latter keep all their contents local there is no way to access it from the outside. The content of refsegments can be easily accessed from the outside, though.

What you have to keep in mind is that \printbibliography does not automatically restrict itself to the current refsegment, you will have to do that manually with

\printbibliography[segment=\therefsegment]

Note also that disambiguation features are applied across refsegments, while refsections keep the disambiguation local.

MWE

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{articleA,
author = {Clark Kent},
title  = {On why superman is stronger than batman},
journal = {The daily planet},
year   = {2016},
}
@article{articleB,
author = {Bruce Wayne},
title  = {On why batman is stronger than superman},
journal = {Wayne Enterprises journal},
year   = {2016},
keywords = {blablabla},
}
\end{filecontents}
\usepackage[backend=biber,style=alphabetic]{biblatex}
\addbibresource{\jobname.bib}
\usepackage[colorlinks]{hyperref}
\hypersetup{urlcolor=blue, citecolor=blue, linkcolor=blue}

\begin{document}

\section{Section Title A}
This is outside any refsection.
Here's a normal reference: \cite{articleB}. 
Here's a reference that's only listed inside a refsection: \cite{articleA}
\printbibliography[segment=\therefsegment,keyword=blablabla]

\newpage
\begin{refsegment}
\section{Section Title B}
\cite{articleA}, \cite{articleB}
\printbibliography[segment=\therefsegment]
\end{refsegment}

\end{document}
moewe
  • 175,683
  • One followup question: printbibliography does not seem to print citations inside the refsegment that happen after it, is there any way to change that behaviour? (For an MWE, just switch the 'cite' line and the 'printbibliography' line in your example) – jpb Apr 10 '16 at 11:26
  • @jpb Mhh, that looks like a bug to me... Let me check. – moewe Apr 10 '16 at 11:31
  • 1
    @jpb I have complained over at the biblatex bug tracker https://github.com/plk/biblatex/issues/406 – moewe Apr 10 '16 at 11:40
  • 1
    @moewe: I asked about this some time ago (https://github.com/plk/biblatex/issues/179). Imho it can't work currently, refsegment is a filter criterium that is created during the compilation, and like \addcategory can take only previous settings into account. – Ulrike Fischer Apr 10 '16 at 12:07
  • Okay, guess I'll have to use the nocite command for now, to ensure that the bibliography contains all the entries it should. – jpb Apr 10 '16 at 12:09
  • There is an unintuitive interaction between hyperref and refsegments: the links created by hyperref always link to the first bibliography in which the citation in listed, not the bibliography in the current refsegment. see MWE in http://tex.stackexchange.com/questions/303503/cite-hyperlink-linking-to-bibliography-in-previous-not-current-refsegment – jpb Apr 10 '16 at 13:16
  • @jpb That you will probably have to live with, how should biblatex decide where to link to when there are several options possible? In that case you probably need Ulrike's split refsection approach. But you will have to ask her about the details. – moewe Apr 10 '16 at 13:25
  • @UlrikeFischer That's pretty much what PLK said, it would have to be done via aux files in (I imagine) a similar fashion to what is currently done with refsections. – moewe Apr 10 '16 at 13:33