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!

Use of LaTeX in Industry

A question on TeX.SX about “How is LaTeX used in industry and what are some examples?” has garnered over 6k views since posted yesterday. I had mentioned during my MOSC talk that LaTeX would be very useful in scenarios where some printable content has to be batch-generated or on-the-fly, and now some actual real life examples are given in the answers.

For example, this website allows users to query transportation timetables and returns the results as a pdfTeX-generated PDF:

And here’s another schedule generated by another German transportation website (PDF):

If you read the other answers, you’ll see what and how LaTeX is used in other companies (besides academic publishers). For example, this answer by Peter Flynn:

As a LaTeX consultancy, we have produced classes and styles for many organisations, including companies, government departments, and non-profits. A London auction house uses LaTeX to generate invoices; an electronic systems training company uses LyX and LaTeX to create their course workbooks and white papers; a Dublin printer uses LaTeX for pharmaceutical labelling; a local government organisation uses TeX to generate the Register of Voters; a professional scientific association uses LaTeX for its regular series of technical reports; and of course we use it internally for client reports, newsletters, and invoicing.

Book Review: LaTeX Beginner’s Guide

(Thanks to Packt for the complimentary eBook copy for this review.)

When I read about the publication of the book on various forums and blogs, my interest was definitely piqued: the author, Stefan Kottwitz, is a frequent and helpful contributor/moderator on TEX.SX. On the other hand I wondered if anyone would actually want to buy an introductory book to LaTeX, considering the many free tutorials and eBooks available on the Web (although there are many out-of-date ones, so beware! See some recommended ones at the end of this post).

After a quick flip — erm, clicks with the mouse — through my complimentary eBook copy courtesy of Packt, I felt the answer was a very firm “YES”. First off, this is certainly an up-to-date book with descriptions of recent packages, and warnings about obsolete ones. While the first few chapter headings read like most other beginner’s guide to LaTeX, Kottwitz’s approach of using complete step-by-step examples throughout the book is something seldom seen in other books or tutorials. By that I mean you don’t just get the first few handful of “Hello World” examples, but for much more advanced usage scenarios as well. (BTW, The examples are based on TeXLive and TeXworks.)

Your mileage may vary, but I do feel that such a hand-holding approach (that’s what my training course had been described as) — at least in the early days of learning LaTeX — is very reassuring. Especially so since LaTeX can be rather intimidating for people who have only used WYSIWYG word processors before. Pop quizzes are interspersed throughout the content (answers in the appendix).

The book has 13 chapters on the following topics:

  1. Getting Started with LaTeX
  2. Formatting Words, Lines, and Paragraphs
  3. Designing Pages
  4. Creating Lists
  5. Creating Tables and Inserting Pictures
  6. Cross-Referencing
  7. Listing Content and References
  8. Typing Math Formulas
  9. Using Fonts
  10. Developing Large Documents
  11. Enhancing Your Documents Further
  12. Troubleshooting
  13. Using Online Resources

While the early chapter headings are kind of expected of any beginner’s guides, they do still contain valuable nuggets. For example, the microtype package is introduced in Chapter 2, as is how to define your own macros with \newcommand. Imagine a beginner’s joy at the even more beautiful typesetting afforded by microtype. And the new-found freedom of defining one’s own commands for consistent typesetting of certain materials. Personally I think such tips, introduced at an early stage, would boost beginner’s confidence in using LaTeX.

While some might consider the installation instructions of TeXLive and TeXworks in Chapter 1 as frivolous, I certainly welcome the instructions on how to install extra packages in Chapter 11.

Chapter 3 on designing pages is particularly useful, as this seems to be one of the most frequently asked beginner’s questions these days. (at least, indicated by the fact that the post on setting page sizes and margins being the 5th all-time most favorite post on this blog.)

I also like the mention of getnonfreefonts in the chapter on fonts. Another favorite chapter of mine is that on Troubleshooting, as this is definitely one of the most important skills if one is to use (and learn!) LaTeX. And everyone who’s going to write a thesis or a business report will definitely want to read Chapter 10 on large documents.

Overall, the book does cover everything a beginner should learn about LaTeX, IMHO anyway. My only nitpicks are that the LaTeX logo isn’t typeset ‘properly’ in the text; and that the LaTeXed output images seem a tad blurry in the PDF eBook version. But these are just petty nitpicks, really.

So do I recommend LaTeX Beginner’s Guide for people interested in learning LaTeX? I’d say Yes. This would be a very nice addition to libraries, or as a communal copy in a research lab, so that newly registered graduate students who’re not yet quite busy with their research can spend their first month learning up LaTeX with it. (You can, of course, get your very own copy; I only mention a communal copy as I know some Malaysians — especially poor grad students — might be reluctant to fork out about RM120 for a book. Everyone really should fork out money to buy a good book sometime, though.)

The book is available as a printed copy (£25.19), eBook copy (£16.14), or multi-format (£28.04). Shipping is free if you’re in UK, US, Europe, Brunei, Hong Kong, Indonesia, Japan, Malaysia, Philippines, Korea, Singapore, Thailand, China, Macau and Taiwan — sweet!

Further Reading

Having said all that, you’ll probably want to complement this beginner’s guide with other, more reference-typed books, such as the LaTeX Companion (I don’t know if the books are available separately), as well as some free (often rather shorter) tutorials and eBooks:

  • Getting to Grips with LaTeX. A personal favorite short beginner’s tutorial.
  • The LaTeX WikiBook. A nice quick online reference.
  • LaTeX and Friends. This is truly a very comprehensive up-to-date eBook for reference purposes (but it does not have complete examples as Kottwitz’s book does). I understand that the author is still updating it from time to time.

LaTeX: More Than Just Academic Papers and Theses

Update 2 July 2011: OK source code uploaded per request, see link below.

So my slides for the talk on LaTeX during MOSC2011 are done and available for download. (This version without animations etc. to minimise the file size. Updated and corrected 30 June 2011; Thanks to Stefan Kottwitz, Felipe and Per for pointing out some mistakes.)

LaTeX: More Than Just Academic Papers and Theses [slideshare id=8408252&w=425&h=355&fb=0&mw=0&mh=0&sc=no]

As mentioned before, it won’t be a tutorial, rather I plan to give teasers of what LaTeX is capable of beyond the usual journal or conference articles. I have undoubtedly left out many interesting use cases, so please don’t flog me if I haven’t included your favorite package or class! 😉 But do drop me a line and we’ll do a future post on it.

(Update: See this post about the Beamer theme used for the slides.)

Typesetting SI Units

Most people would already have heard of the siunitx package, but in case you haven’t, here’s a small, humble request:


Please use the siunitx package more to typeset your measurements. Please. I beg you. It’s so much easier and makes things look so much more professional.

(Yes, this is going to be a rather ranty post, but don’t worry, I’ll keep it short.)

I mean, just compare the output when using siunitx:

\usepackage{siunitx}
\SI{3.563d4}{\square\volt\cubic\lumen\per\farad}

And doing it manually:

$3.563 \times 10^4$ V$^2$ lm$^3$ F$^{-1}$

I rest my case. And if you’re not convinced yet, you can also do lists and ranges of values like this:

\SIlist[per-mode=symbol]{40;85;103}{\kilo\metre\per\hour}
\SIrange{75}{110}{\kilo\pascal}


So please. Start using siunitx.

Upcoming Book Review

Perhaps it’s all the publicity work by the good people behind MOSC 2011 (thank you!), during the last week or two I’ve definitely been getting more LaTeX enquiries (thanks to all of you too!).

So much so that I was very kindly offered by Packt to review a recent book on LaTeX by Stefan Kottwitz!

(The publisher, Packt, specialises in books on open source projects and pays royalties to the projects it publishes about. I’m rather impressed by that.)

I’ve read about the publication of the book on other blogs and forums and my interest was already piqued; not least because Stefan is a very frequent and helpful contributor on TeX.SE.

Well, I have a book to read and a review to write. Stay tuned!

University of Malaya Thesis Class

I have developed a LaTeX class and template for writing an UM (University of Malaya) thesis, complying with the IGS Universiti Malaya IGS Guide to the Preparation of Research Reports, Disertations & Theses, for a friend pursuing her PhD there.

The LaTeX class and template files is available at http://liantze.penguinattack.org/latextypesetting.html#umalayathesis. Hopefully this will be helpful to UM students!

Talk at MOSC2011

My proposed talk on LaTeX has just been accepted by the organisers of MOSC2011.

Now I need to actually write the slides!

Anyway, I plan to speak on “LaTeX: More Than Just Academic Papers and Theses”. It won’t be a tutorial, rather I plan to give teasers of what LaTeX is capable of beyond the usual journal or conference articles.

This will also be my first time attending an OSS conference. I do rather feel queasy at the thought of being intimidated by crusty h4x0rs. 🙂

UPDATE: The organisers have posted my speaker’s profile.

Making Leaflets with LaTeX

Just for fun, I thought I’d make some leaflets to accompany my poster presentation during a recent conference. It would be nice if I could reuse materials from my paper and poster, so I sought for a LaTeX solution, and that solution was the leaflet document class. It automatically sets up a layout for 6 small pages on 2 normal-sized paper pages, so that you can print the output PDF out on double pages, then fold it up into a real, er, leaflet.

Here are the thumbnails of my leaflet, and here are the source code. Notice the little mark (highlighted by the red circle) on the second page to guide you in folding the leaflet. Just make sure that you set your PDF viewer to “Do not scale pages” when printing the PDF.