Closed huijunchen9260 closed 2 years ago
Dear HJ,
the easiest way how to include a CSS is to use the AddCss
configuration. See the documentation for more options. Simple use could look like this:
\Preamble{xhtml}
\Configure{AddCss}{custom.css}
\begin{document}
\EndPreamble
Sorry that I tried but it is still not working. Should I replace the custom.css
into the path to the style.css that I want to use in the compilation? Or where should I "include" the style.css
file?
Yes, replace the custom.css
with style.css
, if that's the filename you use. You can also pass a subdirectory to this command, for example something like:
\Configure{AddCss}{/css/custom.css}
Which will work if you have a /css/custom.css
file on your web server.
This is pretty amazing. Now it is working.
That's good to hear!
I also try to follow the documentation to link to a CSS on some web but constantly failing:
make4ht -c config.cfg syllabus.tex
[STATUS] make4ht: Conversion started
[STATUS] make4ht: Input file: syllabus.tex
[ERROR] htlatex: Compilation errors in the htlatex run
[ERROR] htlatex: Filename Line Message
[ERROR] htlatex: ? 50 File ended while scanning use of \c:@HEAD:.
[ERROR] htlatex: ? 52 LaTeX Error: Missing \begin{document}.
[ERROR] htlatex: ? 60 Undefined control sequence.
[ERROR] htlatex: ? 60 Undefined control sequence.
[ERROR] htlatex: ? 64 LaTeX Error: Missing \begin{document}.
[ERROR] htlatex: ? 64 LaTeX Error: Missing \begin{document}.
[ERROR] htlatex: ? 69 Undefined control sequence.
and this is my config.cfg
:
\Preamble{xhtml}
\Css{body{max-width:70ch;margin: 1rem auto;}}
\Configure{AddCss}{custom.css}
\Configure{@HEAD}{\HCode{<link type="text/css" href="https://huijunchen9260.github.io/style.css"/>}
% \Configure{AddCss}{../../../style.css}
\begin{document}
\EndPreamble
Ah, it seems that there is a missing closing brace in the documentation! It should be:
\Configure{@HEAD}{\HCode{<link type="text/css" href="https://huijunchen9260.github.io/style.css"/>}}
Dear Michal:
Is there any way that I can use -c myconfig.cfg to set up make4ht to use my own CSS file instead of the default one? I want to generate the file that is in the same style of my other webpage but not sure how to do it.
HJ