I produced a song book with the songs package, and now I'd like to have an HTML version of the book, with one song for each page, and an optional clickable index.

I tried the usual LaTeX to HTML converters, but the layout (title, subtitle, ...) gets garbled. Pandoc is not respecting styles (every song becomes a long paragraph <p>...</p> and latex2html is outputing a empty pages.

The closest one is tex4ht which is almost perfect, except for the first verse number, which is not in a new line, but in the same line as the title.

Is there a way to interpret the LaTeX source and convert it to some markup language, so I can format it next (with different classes for elements, so I can use CSS, for example)? I tried PlasTeX, but it's very hard to work with.

A minimal example is this:



\beginsong{Adeste fideles}
Adeste fideles, l\ae ti triumphantes
venite venite in Bethlehem
Natum videte Regem Angelorum:
Venite adoremus, venite adoremus,
venite adoremus Dominum.
En grege relicto humiles ad cunas
vocati pastores adproperant
Et nos ovanti gradu festinemus.
Aeterni Parentis splendorem \ae ternum
velatum sub carne videbimus
Deum infantem pannis involutum. 

\beginsong{Adoro te devote}
Adóro te devote, latens Déitas,
quæ sub his figuris vere látitas;
tibi se cor meum totum súbicit,
quia, te contemplans totum déficit.
Visus, tactus, gustus in te fállitur,
sed áuditu solo tuto créditur.
Credo quidquid dixit Dei fìlius 
nil hoc veritatis verbo vérius.
In cruce latebat sola Déitas,
sed hic latet simul et humánitas:
ambo tamen credens atque cònfitens,
peto, quod petivit latro pænitens.
Plagas, sicut Thomas, non intúeor:
Deum tamen meum te confiteor:
Fac me tibi semper magis crédere,
in te spem hàbere, te dilígere.
O memoriale mortis Dómini,
Panis vivo, vitam præstans hómini:
præsta meæ menti de te vívere,
et te illi semper dulce sàpere.
Pie pellicane, Iesu Dómine,
me immundum munda tuo Sànguine,
cuius una stilla salvum fàcere,
totum mundum quit ab omni scélere.
Iesu, quem velatum nunc aspício,
oro fiat illud, quod tam sitio:
ut te revelata cernens fácie
visu sim beatus tu\ae{} glóri\ae{}. Amen



And this is a sample output: sample tex4ht output

  • 2
    1. Welcome! 2. Could you provide a minimal document, so that we could try? 3. pandoc is usually the software used to convert TeX to markdown or other formats: did you have a look?
    – Clément
    Jan 16, 2017 at 22:29
  • 1
    what do you mean by usual convertors?, which ones?, and with what configuration? It is hard to believe that latex2html, tex4ht, latexml, hevea, for example all garbled the layout the same way. Jan 16, 2017 at 23:18

1 Answer 1


You can add custom CSS convert your file with tex4ht, in this case you need to just take a look at the generated code to find out what elements you need to configure:

class="colorbox" id="colorbox2"><span 
class="ecsx-1728">1</span>    </span>

This is the box with number 1 for your first song. In this case, you need to configure element span with class colorbox. CSS can be introduced using \Css command in the tex4ht configuration file:


Save this configuration as mycfg.cfg and compile your file using

make4ht -c mycfg.cfg filename.tex

This is the result:

enter image description here

There is still lot to be improved, I will revisit it tomorrow.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .