[tex4ht] How to add custom Css code into the configuration file? @media

Michal Hoftich michal.h21 at gmail.com
Wed Aug 30 12:30:54 CEST 2023


>
> Thanks Michal. This is very useful. I did not know about
>
> \Configure{AddCss}{filename.css}
>
> This will make it easy to put all css code in there, so I do not
> have to worry about escaping stuff.
>

Yes, that's the main feature. \Css is meant mainly for smaller chunks
of code and for your custom tags. Design for the whole page is better
to be put in an external file. Another upside is that when you fix
something in the CSS, you don't need to recompile all documents.

> But it is not clear from the docs you have, what the search path for
> the filename.css is.
>
> i.e. now I have one global .cfg file, inside my $texmf
>
>         texmf/tex/latex/make4ht_cfg_folder/nma_mathjax.cfg
>
> And when I compile using mak4ht ... -c nma_mathjax.cfg
> from anywhere in the tree, make4ht finds it.
>
> If I put my filename.css in the same folder as the .cfg, will
> it also find it and read it during compile? Or does it have
> to be in other location such as $HOME to see it?

TeX4ht doesn't read that file at all. It is declared as used, so when
you use the --output-dir option, TeX4ht will try to copy it to that
directory, but other than copying, it doesn't do anything.

As you want to use it on your webpage, I think you could place the CSS
file to a directory on your server, for example:

https://www.12000.org/css/design.css

You can then use

\Configure{AddCss}{/css/design.css}

Web browsers should find the file and use it, because they can use
relative addresses.


Best regards,
Michal


More information about the tex4ht mailing list.