Featured Post

We've moved to tex.my!

It’s been great writing on Blogger.com, but we’ve decided to move to a new platform, thanks to some valuable help from a great, great friend...

Thursday, February 9, 2012

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:

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.




\section{My Academic Portfolio}
\printbibliography[title={Conference Proceedings},type={inproceedings}]


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!


  1. Can you tell us how to covert a XeTeX or LuaTeX file to html?

    1. For XeLaTeX files using the fontspec package, perhaps this link could help: http://wpinbacker.blogspot.com/2011/01/tex4ht-and-xelatex.html

      Basically, it uses the ifxetex package package to hide the fontspec package from tex4ht, so that you can invoke htlatex on the file.

      As for LuaLaTeX, see this Q&A on TeX.SX:

      Hope that helps!

  2. Very useful information for people like me. This will certainly help to avoid some cyclic work. Thanks for the post and great job.

  3. 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}]


    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?

    1. 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).

    2. Ok.
      Gee, wondering why they didn't update the package ever since

    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.