I am using a \Css configuration which centers a caption under a figure thanks to how-to-make-caption-be-centered-under-table-when-using-tex4ht

Now I find this does not work if I change document class to koma-script !

Here is a MWE




\caption{test image}


Now compiled using make4ht -c my.cfg where my.cfg is

\Css{div.figure img {text-align:center;display:block;margin-left:auto; margin-right: auto;}}

Gives the expected output

Mathematica graphics

Now changed the document to


And making no other changes and compiling again using same command, gives

Mathematica graphics

Why would changing the document class makes the CSS configuration have no effect?

TL 2018

1 Answer 1


If you compare the generate HTML files, you will find, that tex4ht adds a table to the caption in case of scrbook:

<div class="caption">
  <table class="caption">
    <tr style="vertical-align:baseline;" class="caption">
      <td class="id">Figure&#x00A0;0.1: </td>
      <td class="content">test image</td>

(I've changed the line breaks and the indent to make it human readable).

With this code not only the text-align but also the table alignment is responsible for the alignment. So you need one more line of css code:

div.caption table{margin: auto;}

This additionally changes the margin of the table. So with

\Css{div.figure img {text-align:center;display:block;margin-left:auto; margin-right: auto;}}
\Css{div.caption table{margin: auto;}}

You'd get what you want.

  • 1
    How do you know that? I don't even have any idea how to find out that!
    – Keks Dose
    Commented Feb 11, 2019 at 12:46
  • 1
    @KeksDose As I wrote: 1st, I've compared the HTML files of using book and of using scrbook. Then, I've made the difference of the scrbook result better human readable. Then, I've had a look into the generated css file to see, whether or not there are already style definitions for table of class caption (in css syntax: div.caption table) or for table rows. Then, I've had a look into the css guide to see, how to reduce the table to its natural width or to change its alignment. That's it. No magic. Only reading code and manuals (and spending some time). Commented Feb 12, 2019 at 6:36

You must log in to answer this question.

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