I need to convert a latex file to MS word which contains a lot of tikz-pictures. To make the conversion more easy, the converter schould automatically replace the tikzpicture blocks with an includegraphics command to to corresponding pdf of the picture and convert before conversion.
Is there any script or converter which can do this?
Best Answer
You can use
tex4ht
to convert LaTeX to OpenDocument format, which can be then easily converted to Word using LibreOffice. It supports TikZ externalization, so you save your drawings in suitable format first and use them in the conversion process afterwards. It seems that the most suitable image format to use ispng
. A vector format likesvg
orpdf
would be better, but they are unsupported in theodt
format, so no luck here, we must stick with bitmaps.You haven't provided a
mwe
, so here is mine:You can compile the document using:
It will create two
png
images.The interesting bits in this TeX file are these
This is configuration for TikZ externalization.
rungs
command is version of GhostScript shipped with TeX distributions, so it should work everywhere. You may want to play with the parameters, in order to get the best result.This piece will ensure that the configuration from the above is used only when the document is not compiled using
tex4ht
, because we need to use special configuration in that case.The configuration for
tex4ht
is provided in a file with.cfg
extension, likemycfg.cfg
:This configuration basically tells TikZ not to generate the images for figures, but to include the
png
images created in the previous step instead.You can compile the document using
tex4ht
now. The command is following:with this result: