[tex4ht] [bug #371] TikZ externalization and PDF images

Nasser M. Abbasi nma at 12000.org
Tue Oct 17 23:26:30 CEST 2017

On 10/16/2017 7:52 AM, Michal Hoftich wrote:
> URL:
>    <http://puszcza.gnu.org.ua/bugs/?371>
>                   Summary: TikZ externalization and PDF images
>                   Project: tex4ht
>              Submitted by: michal_h21
>              Submitted on: Mon 16 Oct 2017 03:52:24 PM EEST
>                  Category: None
>                  Priority: 5 - Normal
>                  Severity: 5 - Normal
>                    Status: None
>                   Privacy: Public
>               Assigned to: None
>          Originator Email:
>               Open/Closed: Open
>           Discussion Lock: Any
>      _______________________________________________________
> Details:
> I've added support for TikZ externalization and for PDF image inclusion.
> The externalization supports means that TikZ will not try to externalize the
> images with tex4ht compilation, saved images will be used instead. So it is
> necessary to compile the document using (pdf|lua|xe)latex first, with
> -shell-escape option. The externalized images will be included as PDF.
> This is connected with the second new feature, which is PDF image support. PDF
> images will be converted to some supported format, I've added support for SVG
> support as default. Inkscape is used for the conversion. New configuration,
> PdfConvert have been added. It has two arguments, first is the image format
> which should be used, the second is a command used for conversion.
> This is the default configuration:
> \Configure{PdfConvert}{svg}{"inkscape -z -f '\Gin at base.pdf' -l
> '\Gin at base.\a:PdfConvert'"}
> I think we can add more configurations and use the command line options for
> choosing among them.
> The main reason to use the externalization instead of the default TikZ support
> for tex4ht, is that it has better support for text nodes  and more TikZ
> features. And also the compilation speed should be better.

Thank you Michal for all of this. I am trying to test
this, but keep getting an error with the .cfg

It might be useful to make a template complete .cfg file for
users to use? Or a small example folder with the
commands you used and put them in zip file to download
and use them as reference?

I put the command you show in my .cfg, but I must be doing
something wrong. I keep getting this error:

make4ht --shell-escape --lua -u -c nma.cfg document.tex

l.13 --- TeX4ht warning --- \Configure{PdfConvert}? ---

! LaTeX Error: Missing \begin{document} in `nma.cfg'.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
l.13 \Configure{PdfConvert}{s
                            vg}{"inkscape -z -f '\Gin at base.pdf' -l '\Gin at base...

? x


Is it in wrong place?

Here is the .cfg I am using. Do I need to keep all the
other configuration in there I had from before? I tried
removing them, but the error still there.

=== nma.cfg========
%this below to make it resize the SVG image, if it is there, to
%what is in the includegraphics.
%thanks to @Michael.h21 for this trick
\newcommand\CalcRem[1]{\strip at pt\dimexpr(#1)/\emwidth}

             {\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}
%added this on oct 17,2017. Per email from  @Michael.h21
\Configure{PdfConvert}{svg}{"inkscape -z -f '\Gin at base.pdf' -l '\Gin at base.\a:PdfConvert'"}
== end nma.cfg ==============

Here is the small latex file I am trying to test with

=== document.tex====



\foreach \n in {1,...,\the\pdflastximagepages} %loop over each page

Just need to put some PDF file to test with.
It compiles OK with lualtex. But gives the above error with
make4ht. I think I have syntax error in my .cfg file?

Running on Linux, latest texlive update.

>which inkscape

>inkscape --version
Inkscape 0.91 r13725

Thank you

More information about the tex4ht mailing list