Creating an Online Academic Portfolio with LaTeX and TeX4ht

This was originally asked on TeX.SX, the requirements being:

Any one know of a good script to turn a bibtex file into a nice academic portfolio that:

  • links to electronic versions where known (from url or doi)
  • works with local files (e.g. with bibdesk’s format or otherwise)
  • automatically creates a thumbnail of the first page
  • and generally produces a polished web page suitable for showing off your work?

Well, I maintain my own online publication list by generating the HTML code from my BibTeX, using BibLaTeX, Biber and TeX4ht. So my answer to the above question was a quick modification of my own workflow, adding Ghostscript to the mix to generate thumbnail images of the papers. The output looks like this: (The publication lists can be split according to their types)

(BibLaTeX is a complete reimplementation of the bibliographic facilities provided by LaTeX in conjunction with BibTeX. It’s very flexible, and many find it easier to deal with compared to the BST language. Biber is the replacement of the BibTeX binary, for users of BibLaTeX.)

The source codes can be downloaded here as a .zip file. Further elaborations follow.

The Bibliography File

Back to the task at hand. First we have the BibTeX file, the content of which is pretty much the norm, except that I used the custom BibLaTeX field to hold the local PDF file name. My publications.bib contains entries like:

@ARTICLE{Lim:Ranaivo:Tang:2011,
author = {Lim, Lian Tze and Ranaivo-Malan\c{c}on, Bali and Tang, Enya Kong},
title = {Low Cost Construction of a Multilingual Lexicon from Bilingual Lists},
journal = {Polibits},
year = {2011},
volume = {43},
pages = {45–51},
url = {http://polibits.gelbukh.com/2011_43/43-06.htm},
usera = {LLT-polibits.pdf}
}

The LaTeX Source File

Next is the portfolio.tex file, in which I set up a hook at every bibliography item to include the first page of the file pointed to by usera. I’ve also added a bibmacro called string+hyperlink, to make the publication title link to the url or doi field if these are available, as shown in this answer.

\documentclass{article}
\usepackage[backend=biber,bibstyle=authoryear,sorting=ydnt]{biblatex}
\usepackage{graphicx}
\bibliography{publications}
\usepackage{hyperref}

\ExecuteBibliographyOptions{doi=false,url=false}
\newbibmacro{string+hyperlink}[1]{%
\iffieldundef{url}{%
\iffieldundef{doi}{#1}{\href{http://dx.doi.org/\thefield{doi}}{#1}}}
{\href{\thefield{url}}{#1}}}
\DeclareFieldFormat*{title}{\usebibmacro{string+hyperlink}{#1}}

\newbibmacro{usera}{%
\iffieldundef{usera}{}{%
\savefield*{usera}{\filename}%
\usebibmacro{string+hyperlink}{\includegraphics[width=100pt]{\filename}}\\}%
}
\AtEveryBibitem{\usebibmacro{usera}}

\begin{document}
\section{My Academic Portfolio}
\nocite{*}
\printbibliography[title={Articles},type={article}]
\printbibliography[title={Conference Proceedings},type={inproceedings}]

\end{document}

TeX4ht Configuration File

I then set up a TeX4ht personal configuration file, called portfolio.cfg (included in the .zip file). It contains some simple CSS, and tells TeX4ht to convert the first page of the local PDFs into PNGs using ghostscript. (So yes you will need to have ghostscript installed for this to work.)

Generating the HTML

Right, now we can run the following commands:

$  htlatex portfolio “portfolio”
$  biber portfolio
$  htlatex portfolio “portfolio”

And you should then get portfolio.html, which you can further embellish with more CSS. Well that was fun!

7 thoughts on “Creating an Online Academic Portfolio with LaTeX and TeX4ht

  1. I tried to compile your original source;

    Package biblatex Warning: Setting 'defernumbers=true' recommended.

    l.24 — TeX4ht warning — Cannot determine size of graphic in cicling2011-pol
    ibits.pdf (no BoundingBox) —
    ! Undefined control sequence.
    … c@refsection -bib@field@entrykey

    l.24 …liography[title={Articles},type={article}]

    and

    Package biblatex Warning: Setting 'defernumbers=true' recommended.

    l.24 — TeX4ht warning — Cannot determine size of graphic in cicling2011-pol
    ibits.pdf (no BoundingBox) —
    ! Undefined control sequence.
    … c@refsection -bib@field@entrykey

    l.24 …liography[title={Articles},type={article}]

    –since I got the same error for my file. any clue how you overcame this before?

  2. It sounds like you have an older version of biblatex. Have you tried updating it? I have

    Package: biblatex 2011/11/13 v1.7 programmable bibliographies

    Also if you're using the TeXLive from the Debian/Ubuntu/Fedora etc repositories, unfortunately those are TeXLive 2009 (or 2008).

  3. You can just install the latest biblatex in your LOCALTEXMF tree then. 🙂

    Some technical issues with packaging TeXLive for Linux distributions:

    1. the many binaries in TeXLive are linked to standard support libraries;
    2. the sheer size of the myriad TeXLive classes and packages, so dividing them up into smaller constituent packages (so that GNU/Linux users can just pick and choose particular packages, not the whole whopping 2GB) is hard and takes time.

    Read more about this at http://www.texdev.net/2011/10/29/tex-live-in-linux-distributions/

    You can install the latest TeXLive by hand (as I have done, although I mainly do LaTeX work in OS X). Apparently you can even “trick” Debian/Ubuntu into believing your manual install is the one from the Debian repositories (http://tex.stackexchange.com/questions/1092/how-to-install-vanilla-texlive-on-debian-or-ubuntu) but I've never really got that to work.

Leave a Reply

Your email address will not be published. Required fields are marked *