The web page entitled “What to do now that I’m retired?” is written using Pandoc, a set of tools supporting an extension of Markdown.

Creating HTML and PDF

The HTML and PDF versions are made from the source text file \(\texttt{WhatToDo.txt}\) using the CSS file \(\texttt{mypandoc.css}\), which is a modified version of \(\texttt{pandoc.css}\) from the Pandoc demos page, and the HTML file \(\texttt{footer}\), which is a modified version of \(\texttt{footer.html}\) from the Pandoc demos page (perhaps unwisely, I omitted the extension \(\texttt{.html}\) to shorten the shell commands below).

The HTML version is made by typing the following into a \(\texttt{bash}\) shell.

\(~\scriptsize\texttt{ pandoc -s -S --toc -c mypandoc.css -A footer --mathjax WhatToDo.txt -o WhatToDo.html }\)

The PDF version is made by typing:

\(~\scriptsize\texttt{ pandoc -s -S --toc WhatToDo.txt -o WhatToDo.pdf }\)

Often I have a link from, say TEXT to a web address, say URL, with the property that the link opens in a new window and is also live in the PDF version. I discovered by experiment that this can be achieved by putting an HTML link inside a Markdown link, i.e. using the horribly ugly

[<a href="URL" target="_blank">TEXT</a>](URL)

instead of the standard Markdown

[TEXT](URL)

I wish I knew a less kludgy method than this. Googling didn’t reveal a better solution. To avoid having manually to write such URLs, I defined Emacs macros for translating between the nice Markdown notation and the horrible HTML expansion. A better way might be to use a Pandoc script, but I don’t have the expertise to implement this.

Inserting Latex commands for the PDF without effecting the HTML

I found that “\textrm{latex command}” executes latex command for the PDF without affecting the HTML. I use this hack in several ways:

  1. to insert text about the figure numbers that only appear in the PDF;
    example: “repeated \textrm{in Figure 2} below”;

  2. to force line breaks in the PDF but not the HTML (four spaces at the end of a line causes a line break in both the HTML and PDF), this is useful when the HTML is good, but the latex paragraph formatting causes stuff to overflow to the right;
    example: “\textrm{\newline}”;

  3. to insert footnotes, usually to give a URL in the PDF, but not in the HTML;
    example: “\textrm{\footnote{\url{http://www.cl.cam.ac.uk/}}}”.


Mike Gordon
Rebuilt: Wed 5 Apr 11:40:30 BST 2017