I've been trying to highlight Python code and convert it to HTML. For highlighting I used the minted package since it provided a few styles that I was looking for and I used htlatex for HTML conversion. Unfortunately, the background is not set as intended.

When using htlatex, I get the following warning:

"Missing \Configure{\HColor}{DarkGrey}{...} (in Latex: gray 0.1)"

Here is the TeX file:


[random python code here...]


htlatex is called like so:

htlatex test.tex "" "" "" -shell-escape

I am a complete newbie when it comes to latex and I'm probably missing something obvious here. Any help is much appreciated!

  • 1
    Welcome to TeX.SX! – yo' Jan 30 '15 at 23:24
  • @yo Thanks :) Not new to stackexchange sites in general but I should be sticking around here for a while until I am more proficient with LaTeX ! – Veritas Jan 30 '15 at 23:34
  • Well, usually we include a link with the welcome message, that is intended to the newbies. I noticed that you came with 101 rep, so you're not that much new to SE ;) – yo' Jan 30 '15 at 23:38

It seems that minted uses \colorbox for colored background, which is supported by tex4ht, we only need to configure it to support DarkGray color.

Create file hello.cfg:


and compile with

htlatex test.tex "hello" "" "" -shell-escape

\#1A1A1A is hexadecimal value of your dark gray color. Unfortunately, this isn't all what needs to be done. minted package doesn't have it's own configuration file for tex4ht, but uses supported packages, so it more or less works. There is a problem with your example though. Generated code listing doesn't have gray background. Why? It is evident from generated html code:

<p class="noindent" >
class="colorbox" id="colorbox8"></p><div class="minipage"><div class="fancyvrb" id="fancyvrb1"><a 

<span class="colorbox"> which is our colorbox is immediately closed by </p> tag! To solve that, we need to configure minted environment to close previous paragraph. This is common issue, see Control the <p> tags added by tex4ht.

Modify the config file:


This closes the paragraph before minted environment, resp. doesn't create one, as in your example there are no paragraphs:

class="colorbox" id="colorbox8"><div class="minipage"><div class="fancyvrb" id="fancyvrb1"><a 

of course, it still doesn't work, probably because of some html or css rules. Fortunately, solution is easy, we just need to declare span.colorbox to have display:block css property:


and the result:

enter image description here

| improve this answer | |
  • Thanks for the incredible answer! I sure have a lot of things to read about. – Veritas Feb 2 '15 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.