[tex4ht] Question on using .cfg and \DeclareGraphicsExtensions

Nasser M. Abbasi nma at 12000.org
Wed Oct 10 22:24:42 CEST 2018


Thanks Michal,

The command \@ifpackageloaded{graphicx} worked great, I did
not know about it.

Best,
--Nasser

On 10/10/2018 2:15 PM, Michal Hoftich wrote:
> 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