[tex4ht] Question on using .cfg and \DeclareGraphicsExtensions

Michal Hoftich michal.h21 at gmail.com
Wed Oct 10 21:15:25 CEST 2018


Hi Nasser,

> The use of \DeclareGraphicsExtensions{.svg,.png} is needed
> to allow the code below it to work.
>
> The above works well, as long as I make sure to
> add
>
> \usepackage{graphicx}
>
> in each Latex file which is being compiled by make4ht,
> otherwise will get an error

you can use \@ifpackageloaded{graphicx} for test of its presence. The
full configuration file is bellow:

-----------------------
\RequirePackage{mathjax-latex-4ht}
\Preamble{xhtml}

\makeatletter
\@ifpackageloaded{graphicx}{%
\DeclareGraphicsExtensions{.svg,.png}

%this below to make it resize the SVG image, if it is there, to
%what is in the includegraphics.
%thanks to @Michal.h21 for this trick
\newcommand\emwidth{10}
\newcommand\CalcRem[1]{\strip at pt\dimexpr(#1)/\emwidth}
\Configure{graphics*}
           {svg}
            {\Picture[pict]{\csname Gin at base\endcsname.svg
            \space style="width:\CalcRem{\Gin at req@width}em;"
            }%
            \special{t4ht+ at File: \csname Gin at base\endcsname.svg}
           }
}{}
\makeatother
\Configure{Picture}{.svg}
\begin{document}
\edef\mymathjaxconf{\detokenize{MathJax.Hub.Config({
        TeX: {
  MAXBUFFER: 40*1024,
  Macros : {
relax: "{}",
setlength: ["{}", 2],
allowbreak: "{}",
}},
});}}

\ExplSyntaxOn
\regex_replace_all:nnN{ \x{23}\x{23}}{\x{23}}{\mymathjaxconf}
\ExplSyntaxOff

\Configure{@HEAD}{\HCode{<script
type="text/x-mathjax-config"> \mymathjaxconf</script>}}

\EndPreamble
--------------------

Best regards,
Michal


More information about the tex4ht mailing list