[tex4ht] help on syntax add a \Configure{@HEAD}

Michal Hoftich michal.h21 at gmail.com
Wed Jan 8 16:24:24 CET 2014


Hello,

the issue here is that TeX commands are expanded in \HCode{}, so in
your case these lines are causing troubles:

  inlineMath: [ ['$','$'], ["\\(","\\)"] ],
  displayMath: [ ['$$','$$'], ["\\[","\\]"] ]

you have to prevent expansion of these commands and characters. You
can use `\unexpanded` for this purpose, this works for me:

 \Configure{@HEAD}{\HCode{%
     <script type="text/x-mathjax-config">\Hnewline
       MathJax.Hub.Config({\Hnewline
         extensions: ["tex2jax.js"],
         jax: ["input/TeX", "output/HTML-CSS"],
         tex2jax: {
           \unexpanded{inlineMath: [ ['$','$'], ["\\(","\\)"] ],}\Hnewline
           \unexpanded{displayMath: [ ['$$','$$'], ["\\[","\\]"] ],}\Hnewline
           processEscapes: true
         },
         "HTML-CSS": { availableFonts: ["TeX"] }
       });\Hnewline
     </script>
  }}

Best regards,
Michal

2014/1/8 Nasser M. Abbasi <nma at 12000.org>:
>
> I've always had hard time adding HTML code to my .cfg file
> as I am not sure what the syntax is supposed to be in
> terms of when to use \Hnewline and if I need to escape
> some characters and such.
>
> I am now trying to add an additional mathjax configuration
> item. The HTML itself is shown at mathjax web site below
>
> http://docs.mathjax.org/en/latest/configuration.html
>
> Here it is
> ------------------
> <script type="text/x-mathjax-config">
>   MathJax.Hub.Config({
>     extensions: ["tex2jax.js"],
>     jax: ["input/TeX", "output/HTML-CSS"],
>     tex2jax: {
>       inlineMath: [ ['$','$'], ["\\(","\\)"] ],
>       displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
>       processEscapes: true
>     },
>     "HTML-CSS": { availableFonts: ["TeX"] }
>   });
> </script>
> -------------------
>
> To add this to my .cfg file, I copied the above and added
> it inside
>
> \Configure{@HEAD}{\HCode{ .. HERE .... }}
>
> I tried adding \Hnewline in few places, but nothing helped. Here
> is what I have now
>
> -------------------------------
>  \Configure{@HEAD}{\HCode{
>      <script type="text/x-mathjax-config">
>        MathJax.Hub.Config({
>          extensions: ["tex2jax.js"],
>          jax: ["input/TeX", "output/HTML-CSS"],
>          tex2jax: {
>            inlineMath: [ ['$','$'], ["\\(","\\)"] ],
>            displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
>            processEscapes: true
>          },
>          "HTML-CSS": { availableFonts: ["TeX"] }
>        });
>      </script>\Hnewline
>   }}
> -----------------------
>
> When I run a tex file that uses the above .cfg,
> I get syntax errors:
>
> --------------------------
> ! Undefined control sequence.
> \\  ->\let \reserved at e
>                \relax \let \reserved at f \relax \@ifstar {\let \reserv...
> l.213 \EndPreamble
>                   ?
> --------------------------
>
> I put a copy of my complete .cfg file in this folder:
>
> http://12000.org/tmp/080114/
>
> if someone like to see the whole file. Here is a test:
>
> ----  foo.tex -----
> \documentclass{article}%
> \begin{document}
> test
> \end{document}
> ------------------
>
> htlatex foo.tex  "nma.cfg"
>
> and the error will show up. I think it is an escape character
> issue?
>
> texlive 2013, on linux machine
>
> thank you,
> --Nasser
>
>
>
>
>
>
>


More information about the tex4ht mailing list