0

I'm working on a book with highly stylized references. I use a special macro called \fcite that creates a footnote with the author's name, the work's title, and the date. The bibliography is also stylized. And there's random Unicode in some of our bibliographic entries. So we are using:

  • xelatex
  • bibtex (biber gave us errors and runs way to slow)
  • biblatex
  • hyperref

I can't get the footnotes to link properly to the bibliography items.

Here is a mwe for mwe.tex:

\documentclass[12pt,english,twoside]{report}
\usepackage{xspace}
\usepackage[backend=bibtex,language=american,style=authoryear]{biblatex}
\usepackage[hidelinks,breaklinks,hyperindex=true]{hyperref}
\newcommand{\fcite}[2][]{\footnote{\citeauthor{#2}, \emph{\citetitle{#2}} (\citeyear{#2})\xspace#1\xspace}}
\addbibresource{mwe}
\begin{document}
This isn't Knuth,\fcite{knuth} you know.
\printbibliography
\end{document}

And here is the mwe.bib:

@book{knuth,
author = {Knuth, Donald E.},
title = {The TeXbook},
year = {1986},
isbn = {0201134470},
publisher = {Addison-Wesley Professional}
}

And here is the Makefile:

mwe.pdf: mwe.tex mwe.bib
    xelatex mwe
    bibtex mwe
    xelatex mwe
    xelatex mwe

The result looks great, but I don't get a link. I've tried changing:

\newcommand{\fcite}[2][]{\footnote{\citeauthor{#2}, \emph{\citetitle{#2}} 

to:

\newcommand{\fcite}[2][]{\footnote{\hyperlink{cite.#2}{\citeauthor{#2}, \emph{\citetitle{#2}}}

But that doesn't work either.

How do I make the footnotes link to the bibliography items?

Also, is there an easier way to make this all work? Everything seems kind of hodge-podge at this point.

moewe
  • 175,683
vy32
  • 4,780

1 Answers1

1

The best way to define a \...cite-like command in biblatex is with \DeclareCiteCommand. Putting several different \...cite commands in a \newcommand usually produces inferior results (it takes effort to deal with pre- and postnotes properly, the citation trackers may be thrown off, linking might not work as expected, ...).

Usually the main part of the work done by a citation command defined with \DeclareCiteCommand is handled by a corresponding bibliography macro. In the following our bibmacro fcite is based on the standard cite bibmacro from authoryear.cbx (ll. 10-18 in v3.15a). We just add code to always print the labeltitle and make sure the linking always applies to the whole citation output.

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

\usepackage[backend=bibtex, style=authoryear]{biblatex} \usepackage[colorlinks,citecolor=blue,hyperindex=true]{hyperref}

\newbibmacro*{fcite}{% \printtext[bibhyperref]{% \iffieldundef{shorthand} {\ifnameundef{labelname} {\iffieldundef{label} {} {\printfield{label}% \setunit{\printdelim{nametitledelim}}}} {\printnames{labelname}% \setunit{\printdelim{nametitledelim}}}% \printfield[citetitle]{labeltitle}% \setunit{\addspace}% \DeclareFieldFormat{labeldate}{\mkbibparens{##1}}% \printlabeldateextra} {\printfield{shorthand}}}}

\DeclareCiteCommand{\fcite}[\mkbibfootnote] {\usebibmacro{prenote}} {\usebibmacro{citeindex}% \usebibmacro{fcite}} {\multicitedelim} {\usebibmacro{postnote}}

\DeclareMultiCiteCommand{\fcites}[\mkbibfootnote]{\fcite}{\multicitedelim}

\DeclareAutoCiteCommand{fcite}[l]{\fcite}{\fcites} \ExecuteBibliographyOptions{autocite=fcite}

\addbibresource{biblatex-examples.bib}

\begin{document} Lorem \autocite{sigfridsson} ipsum \autocite{nussbaum} dolor \autocite{geer}

\printbibliography \end{document}

Linked footnotes with author, title and year.


If you need different footnotes for different entries in the same \fcite, you can use the following slightly modified definitions

\DeclareCiteCommand{\fcite}
  {}
  {\mkbibfootnote{%
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \usebibmacro{citeindex}%
     \usebibmacro{fcite}
     \ifnumequal{\value{citecount}}{\value{citetotal}}
       {\usebibmacro{postnote}}
       {}}}
  {}
  {}

\DeclareMultiCiteCommand{\fcites}{\fcite}{}

of course that comes with its own set of problems (two consecutive footnotes generally look odd and could even be confused for a single footnote with a different number).


In the question you mention random Unicode characters in the bibliography. I'm not quite sure I understand what that means, but please keep in mind that BibTeX does not understand Unicode at all. Non-ASCII characters need to be given with their LaTeX-macro escape: How to write “ä” and other umlauts and accented letters in bibliography?. In most situations Unicode characters are just passed through as is, but in some situations (e.g. sorting or when BibTeX needs to count characters, for example for name initials) Unicode characters can cause major (or minor) headaches. biblatex's full Unicode support is only available with Biber. (That's one of the reasons why Biber is slower: It needs to deal with all of Unicode, not just ASCII. That's also one of the reasons Biber is sometimes more picky about certain files. BibTeX doesn't care about your file encoding, it will just read it as ASCII, but Biber needs to know the correct file encoding.)

moewe
  • 175,683
  • One more question: my co-author likes to have multiple references each appear in their own footnote. Any clue how we would do that? – vy32 Dec 27 '20 at 14:06
  • This is really great work! Even the optional argument works properly. – vy32 Dec 27 '20 at 14:23
  • @vy32 I've added a suggestion. But I can't recommend using it. – moewe Dec 27 '20 at 17:43