Search code examples
htmllatexpandoc

Add hyperlinks for BibLaTeX citations by using Pandoc and LaTeX to generate HTML


I have the following minimal LaTeX example.tex file

\documentclass[12pt]{article}

\usepackage[style=authoryear, natbib=true]{biblatex}

\addbibresource{bibliography.bib}

\usepackage{hyperref, lipsum}
\hypersetup{colorlinks, citecolor=red}

\title{Test}

\begin{document}

\maketitle

\section{Introduction}

Read the paper by \citet{Labov1972}.

\section{Results}

The sky is blue \citep{Labov1972}.

\printbibliography

\end{document}

And the following bibliography.bib file in the same directory

@book{Labov1972,
    Address = {Philadelphia},
    Author = {William Labov},
    Publisher = {University of Pennsylvania Press},
    Title = {Sociolinguistic Patterns},
    Year = {1972}}

When I compile them with pdflatex the output is as expected

pdflatex PDF output

Then I convert the example.tex file to HTML5 using Pandoc, while also producing numbered sections --number-sections, a table of contents --toc, and including the citations in the text --citeproc as follows

pandoc example.tex -f latex -t html5 -s -o index.html --bibliography bibliography.bib  
--citeproc -V colorlinks=true -V citecolor=red -V mainfont="Tahoma" --toc 
--number-sections

This produces the following good HTML5 output with a proper clickable table of contents, hyperlinks to the relevant Section, and references.

However, the citations do not include hyperlinks to send to the References section.

Ideally, I would like to include hyperlinks to the relevant DOI paper version online. However, a hyperlink to the References section is also acceptable.

Pandoc HTML output

Note: I tried to ask this question on tex.stackexchange, but it was closed as off-topic there. This seems like the next best place to ask this question. There is a similar question here about MarkDown, but it does not address my LaTeX question.


Solution

  • Set the link-citations metadata value, e.g. by passing --metadata link-citations on the command line. The citation dates will be turned into links, same as in the LaTeX-generated PDF.

    See here for additional ways to configure pandoc's citation processor.