2

I have a document with a customized bibliography. What I mean, is that the bibliography is done manually to insert custom stuff inside it. The following MWE illustrates my issue. The links generated by the \cite commands points to the first page of the document and not to the page where the bilio is. I guess this is the normal behavior, because I don't have \bibliography command. How can I solve this ?

\documentclass[a4paper, 12pt]{article}

%% Bibliography %%
\usepackage[backend=bibtex]{biblatex}
\newcommand{\itembib}[1]{\item[\cite{#1}] \fullcite{#1}}
\begin{filecontents}{mybib.bib}
  @article{Article1,
    author={Manu},
    title={A nice paper},
    journaltitle={Journal 1},
    year=2017
  }
  @article{Article2,
    author={Max},
    title={A nice paper again},
    journaltitle={Journal 2},
    year=2016
  }
\end{filecontents} 
\addbibresource{mybib.bib}

%% hyperref %%
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{
  colorlinks, linkcolor={red!50!black},
  citecolor={blue!50!black}, urlcolor={blue!80!black}
}

\begin{document}

\begin{titlepage}
  TITLE
\end{titlepage}

\newpage
\tableofcontents

\newpage
\section{INTRODUCTION}
Blabla

\newpage
\section{BIBLIO}
\subsection{Subsec 1}
\begin{itemize}
  \itembib{Article1}
\end{itemize}
\subsection{Subsec 2}
\begin{itemize}
  \itembib{Article2}
\end{itemize}
\newpage
\section{CHAPTER 1}
Blabla\cite{Article1}.

\newpage
\section{CHAPTER 2}
Blabla\cite{Article2}.

\end{document}
  • Do you also have a real \printbibliography or do you do everything with your \itembib? What is \itembib for anway? – moewe Mar 16 '18 at 17:01
  • @moewe no I don't have \printbibliography. \itembib is shown on my MWE. – Manuel Selva Mar 16 '18 at 17:15
  • I see that \itembib is in your MWE I was just wondering whether you should better use \printbibliography with a few modifications instead of the hacky \itembib. If I knew what it is used for maybe I could find a way to make \printbibliography work for you (XY-problem). The immediate problem is that only entries in \printbiblioghraphy set an anchor to be linked to. \fullcite does not set an anchor (that makes sense because it is a citation command and citation command can be used multiple times for the same entry, but normally there is only one bibliography that contains an item) – moewe Mar 16 '18 at 17:30
  • What I want to achieve, is simply what i showed in the MWE: A custom bibliography section where papers are gathered under different sub and subsub sections with a particular order. – Manuel Selva Mar 16 '18 at 19:57
  • 2
    @moewe: I think your right (+1, by the way) – user31729 Mar 17 '18 at 7:29
9

By default biblatex only assigns a link anchor for an entry in the bibliography. In particular \fullcite does not get an anchor to link back to. This makes sense because the anchor for an entry should be unique and it is normally reasonable to assume that an entry will only occur in one bibliography. On the other hand, entries may be cited more than once and \fullcite is still at its heart a citation command.

You can use

\makeatletter
\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}
  {\blx@anchor%
   \usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}
\makeatother

to make \fullcite produce the anchor that would normally be produced in the bibliography. Linking should then work as normal. Of course this goes horribly wrong if you \fullcite the same item more than once or if you use \printbibliography after all.

| improve this answer | |
  • 2
    For what it's worth, I don't think \itembib is the ideal solution here. This may well be an XY problem... – moewe Mar 17 '18 at 6:51
  • Thank you very much for the answer, and sorry for the acceptance delay, I have been fully busy with other stuff up to now. I am happy with this hack solution. Nevertheless I am not sure to understand what an "XY problem" is and would be happy to have a cleanest solution. – Manuel Selva Mar 21 '18 at 15:43
  • I am saying that I would be happy with a cleanest solution, because this one still have an incovenient: in my bibliography section I have hyperlinks to themselves. Indeeded, I am using the \cite command to define a biblio item :( – Manuel Selva Mar 21 '18 at 15:50
  • @ManuelSelva That depends on what you need. Maybe you can ask a new question explaining what you need your \itembib for and why you can't use \printbibliography. (XY Problem -> tex.meta.stackexchange.com/q/2449/35864) – moewe Mar 21 '18 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.