0

I would like to know if there is a way to get links and backref links on a \citefield command. For example, I want to cite only the title of a reference:

\citefield{ref}{title} 

or any other field, and get the hyperlink to the reference and the corresponding backref link.

EDIT:

MWE

\documentclass{article}
\usepackage[backref=true]{biblatex}
\usepackage{hyperref}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo}, 
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

Some text \cite{A01,B02}.

\newpage

In this cite \citefield{A01}{title} I do not get any link

\clearpage

Some more text \cite{A01}.

\printbibliography

\end{document}
4

As it is another approach on a lower level, I'll write it as another answer.

You also can patch the \citefield-command using the xpatch-package. Therefore you just have find its underlying macro which will be invoked by it: \blx@cite@citefield

You won't be able to use \citefield{author} as you wanted, because its internally not handled as a field but as a name, so you also had to patch \citename, if you want to use \citename{key}{author}. The third command in this row is \citelist which you also may have to patch. See biblatex-manual, 3.7.7 Low-level Commands.

My example contains patches for all three, but \citename and \citelist only in comments and untested. (It doesn't make much sense to me to use them in this way.)

If you really want to have ONE command like \citeany{key}{field/name/list}, I guess, you had to implement a new macro with an internal switch which leads to the macros \citefield, \citekey, \citelist depending on the given field/name/list. But this is rather more difficult, as you have to deal with the 5 optional parameters from the cite-commands. I don't know how to do this.

\documentclass{article}
\usepackage[backref=true,backend=biber]{biblatex}
\usepackage{hyperref}
\usepackage{filecontents}
\usepackage{silence}\WarningFilter{latex}{Overwriting file}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
url = {http://www.something.com}
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo}, 
}
\end{filecontents}

\addbibresource{\jobname.bib}

\usepackage{xpatch}
\xpatchcmd{\blx@cite@citefield}{\printfield[#4]{#5}}{\printtext[bibhyperref]{\printfield[#4]{#5}}}{}{}%patch \citefield
% \xpatchcmd{\blx@cite@citename}{\printnames[#4]{#5}}{\printtext[bibhyperref]{\printnames[#4]{#5}}}{}{}%patch \citename
% \xpatchcmd{\blx@cite@citelist}{\printlist[#4]{#5}}{\printtext[bibhyperref]{\printlist[#4]{#5}}}{}{}%patch \citelist


\begin{document}

Citefield A01 title: \citefield{A01}{title}.

\clearpage
Citefield B02 title: \citefield{B02}{title}.

Citefield A01 url: \citefield{A01}{url}.

\printbibliography

\end{document}
3

I don't know a solution for \citefield. But you can declare a new citecommand which will print out the specific wanted field. In the example below, I declare a new citecommand \citetitle* (I don't know how to overwrite \citetitle). Then you just have to wrap an \printtext[bibhyperref] around the output \printfield...

MWE:

\documentclass{article}
\usepackage[backref=true]{biblatex}
\usepackage{hyperref}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo}, 
}
\end{filecontents}

\addbibresource{\jobname.bib}

\DeclareCiteCommand*{\citetitle}%your new citecommand \citetitle*
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
    \printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}%like \citetile, 
    %only added \printtext[bibhyperref]{...} in this line
  {\multicitedelim}
  {\usebibmacro{postnote}}


\begin{document}

Some text \cite{A01,B02}.

\newpage

In this cite \citetitle*{A01} I do get a link now.

\clearpage

Some more text \cite{A01}.

\printbibliography

\end{document}
  • Thanks. The problem is that with \citefield I do not get any link. No problems with \cite, \autocite, etc. – Pep May 8 '14 at 13:56
  • You're totally right. I'll update my answer. – musicman May 8 '14 at 14:27
  • Thank you very much! That was initially my idea, but since I want to print any field, I was wandering if there is any general way of doing it with \citefield so I do not have to declare a cite command for every field I want to print/cite. Can \DeclareCiteCommand take an argument? Thank would be one possible solution, but I do not know how to do it. – Pep May 8 '14 at 15:12

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.