I use imagemagick to convert pdf file to image when creating tikz code in latex file. The code is as follows:
\documentclass[preview,border=2pt,2pt]{standalone}
\documentclass[convert={density=300,outext=.png}]{standalone}
...
But 2nd line to invoke imagemagick convert does not work. I need help on this. Thanks.
Best Answer
The example in the question has two
documentclass
commands, which is not allowed in LaTeX. You can use a single command with theconvert
option added to the options of the first line.Note that the second
2pt
option does not do anything, it generates a warning and it can be removed. Note also that you need to run LaTeX with theshell-escape
option to allow callingconvert
. I don't use TeXstudio myself but according to How to invoke latex with the -shell-escape flag in TeXMakerX? you can do it in various ways, one of which is to add a compile directive at the start of the file as in the example below.MWE:
Result (note that the squares indicate transparency, they are shown because they are invisible):
Apart from the
.png
the.pdf
is also generated automatically.