%%%%%%% Example 1. that works correctly %%%%%%%%%%%%%%%%%%%%

%%%%%%% Example 2. fails to insert </div> at \end{center} %%

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuerid, vulputate a, magna.

Hello everyone!

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."




$ make4ht -u -c mwe.cfg mwe.tex

With standalone produces mwe.html: (screenshot from browser)

standalone documentclass - screenshot from browser

Everything from "Hello everyone!" onwards is centered. This is due to missing </div> that should close <div class="center"> in the compiled html. Compiling with \documentclass{article} produces expected result: (screenshot from browser)

article documentclass - screenshot from browser

I have two questions:

  1. How to fix this? Should I file a bug report?

  2. What is recommended documentclass when compiling to html with TeX4ht (make4ht more specifically) and would it be possible to ignore documentclass in tex source file and use another class instead? Mass editing of my ~1000 standalone snippets that are used also for other purposes isn't an option unfortunately.

1 Answer 1


It seems that standalone somehow redefines the way environments are handled and it causes that code which inserts HTML tags at the end of an environment isn't executed. It happens not only to center, but to any other environment, such as itemize, etc.

I haven't found the cause of this trouble, but it can be fixed with simple hack:

% standalone.4ht



The two redefined macros originally executes standalone redefinitions, so it is possible that you will find more issues on your real-world examples. It it works, I will update the source code of tex4ht.

Regarding your second question, we hope that all document classes works, but standard article or book classes have best support.

This is the result:

enter image description here

  • The hack indeed fixes the div-tag problem. The document also compiles ok but the hack changes things like indentation and paragraph breaks which is undesired. I think I split the second question into its own thread. Commented Sep 3, 2017 at 12:52
  • @Jarno_C-137 OK, it will be indeed better to post detailed example of new issues as separate question.
    – michal.h21
    Commented Sep 3, 2017 at 12:57

You must log in to answer this question.

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