[tex4ht] How to include Configuration commands inside the .tex file and not in separate file?

Nasser M. Abbasi nma at 12000.org
Thu Jun 6 11:19:01 CEST 2013


On 6/1/2013 12:41 PM, Michal Hoftich wrote:
> You don't need \Preamble and \EndPreamble in your document, they are
> useful only in config file. You can use \Css, \Tg or \ConfigureEnv,
> but only after '\begin{document}'. Something like this should work:
>
> \documentclass{article}
> \usepackage{somepackage}
> \begin{document}
>   \ifx\HCode\undefined \else
>   \Css{body{background-color:green;}}
>   \ConfigureEnv{quote}{\Tg<quote>}{\Tg</quote>}{}{}
>   \fi
>
> \ifx\HCode will ensure that this code run only when tex4ht is loaded.
>
> Regards,
> Michal
>

Thanks Michal;

The above works on some configurations.

But I can't get this to work for loading mathjax.

I have .cfg where I tell htlatex to use MathJax. When I use
the .cfg, it works.

When I copy the content of the .cfg and put it in the .tex
file as you showed, then it does not work. i.e. the resulting
html file does not have in its header the code to load mathjax.

Can you please tell me what I am doing wrong? Here is
the .cfg

-----------------
\Preamble{xhtml,mathml}
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{}
\Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
(http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link
          rel="stylesheet" type="text/css"
          href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}
\Configure{@HEAD}{\HCode{<script type="text/javascript"\Hnewline
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"\Hnewline
></script>\Hnewline}}
\Configure{@HEAD}{\HCode{<style type="text/css">\Hnewline
   .MathJax_MathML {text-indent: 0;}\Hnewline
</style>\Hnewline}}
\begin{document}
\EndPreamble
---------------------

Here is the tex file:

------------------
\documentclass[12pt,titlepage]{article}%
\begin{document}
$\sum F_{v}=0$
\end{document}
-------------------

Now

htlatex t.tex "t.cfg"

generates t.html which correctly works. i.e. it load mathjax for the math.

Now I copy the content of the .cfg and change the .tex to this:

-----------------------------
\documentclass[12pt,titlepage]{article}%
\begin{document}

\ifx\HCode\undefined \else

\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{}
\Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
(http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link
          rel="stylesheet" type="text/css"
          href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}
\Configure{@HEAD}{\HCode{<script type="text/javascript"\Hnewline
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"\Hnewline
></script>\Hnewline}}
\Configure{@HEAD}{\HCode{<style type="text/css">\Hnewline
   .MathJax_MathML {text-indent: 0;}\Hnewline
</style>\Hnewline}}

\fi

$\sum F_{v}=0$
\end{document}
----------------------

and now call htlatex as (notice no use of .cfg now)

htlatex t.tex "xhtml,mathml"

and when I look at the t.html, it is NOT using mathjax.

I tried many different combinations of the above, but none is
working. Only when I put the configuration in .cfg it works.

Any idea why or what Am I doing wrong?

ps. I was trying to debug this problem to see why it happes

"Bad mathchar (79119) using htlatex+mathml with \uparrow with align from amsmath package"

http://tex.stackexchange.com/questions/116340/bad-mathchar-79119-using-htlatexmathml-with-uparrow-with-align-from-amsmath

thanks,
--Nasser



More information about the tex4ht mailing list