[tex4ht] SVG figures cause font styling to be lost

Michal Hoftich michal.h21 at gmail.com
Tue Jun 2 17:58:22 CEST 2015


The problem is that tikz driver for tex4ht contains this line:

  \Configure{htf} {0}{+}{<tspan font-family="}{\%s}{"
font-size="\%s}{}{}{">}{</tspan>}%

this insert instruction for tex4ht command to output all fonts in
`<tspan>` element.But it isn't reset after end of tikz picture, so all
font commands issue `<tspan>` afterwards. The solution isn't
universal, because each output format uses different
`\Configure{htf}`, but for html, you may use this:

\usepackage{tikz}
\begin{document}
\let\oldtikzminipage\endtikzpicture
\def\endtikzpicture{\oldtikzminipage%
\Configure{htf}{0}{+}{<span\Hnewline
     class="}{\%s}{-\%s}{x-x-\%d}{}{">}{</span>}
}

this is the default configuration from tex4ht-html4.tex inserted into
`\endtikzpicture`, which is called after each tikz picture.

Best regards,
Michal

On Mon, Jun 1, 2015 at 1:33 AM, Nasser M. Abbasi <nma at 12000.org> wrote:
> I can't tell why it does not work when including the tex
> source code for the tikz pic.
>
> But here is a workaround. The result is in a zip with my .cfg included
> which is at this link:
>
> http://12000.org/tmp/053105/bobs_figures.zip
>
> I changed your latex file to be to include the image itself
> instead of include the tikz code. This means some pre-processing
> is needed:
>
> -------------------------------------------
> \documentclass{article}
> \usepackage{graphicx}
> \begin{document}
>
> Here \textbf{is} a \texttt{circuit} for \textit{you}.
>
> \begin{figure}[!ht] \centering
> \includegraphics[width=0.5\paperwidth]{book_figs/t_circuit}
> \caption{Here \textbf{is} a \texttt{circuit} for \textit{you}.}
> \end{figure}
>
> Here \textbf{is} a \texttt{circuit} for \textit{you}.
> \end{document}
> -----------------
>
> Then made the tikz file to be self contained document:
>
> ----------------------------------
> \documentclass{standalone}
> \ifdefined\HCode
> \def\pgfsysdriver{pgfsys-tex4ht.def}
> \fi
> \usepackage{tikz}
> \begin{document}
> \begin{tikzpicture}[scale=2.54]
> .....
> \end{tikzpicture}
> \end{document}
> -----------------------------
>
> Then compiled it
>
> pdflatex t_circuit.tex
>
> then convert to svg using
>
> pdf2svg t_circuit.pdf t_circuit.svg
>
> and now build the main tex file using:
>
> make4ht -d html -c nma.cfg my_fig.tex
>
> Now it work. The fonts changes correclty below the image.
>
> The zip file has the .cfg and the generated HTML so you can see the result.
>
> Again, I do not know why it does not work when including the tikz source
> code directly.
>
> --Nasser
>
>
> On 5/31/2015 4:14 PM, Bob Plantz wrote:
>>
>> > I use Dwight Aplevich's circuits macros to create drawings, which
>> > produces
>> > .tex files. htlatex creates great svg files for the drawings. However,
>> > after the first such drawing, all font styling (bold, italic, etc.) is
>> > lost.
>> >
>> > I have traced the problem to a switch from <span> to <tspan> in the html
>> > code at the point of the first use of svg. Is there a workaround for
>> > this
>> > bug?
>> >
>> > I have attached an example. I'm using texlive 2014 in Ubuntu 15.04. The
>> > attached example can be expanded with
>> >        tar xvfz bobs_figures.tgz
>> > Then
>> >        cd bobs_figures
>> >        htlatex my_fig.tex
>> > gives the example.
>> >
>> > The problem still exists when I use make4ht.
>> >
>> > --Bob
>> >
>
>
>


More information about the tex4ht mailing list