2

This is a specific problem, but I find it comes up often in my workflows:

  • generate a standalone tikz diagram with:
    • some transparent object(s) - i.e. opacity < 1
    • arrows, where I prefer the large style: > = Latex from the tikz library arrows.meta
  • run ImageMagick convert to convert .pdf to .png

The problem is, Latex style arrowheads develop a weird inner border on conversion to .png.

MWE

mwe.tex:

\documentclass[margin=0.1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
  \draw[>=Latex,<->,opacity=1.00](0.0,-0.0)--(1.0,-0.0); % (1)
  \draw[>=Latex,<->,opacity=0.99](0.0,-0.2)--(1.0,-0.2); % (2)
  \draw[>=latex,<->,opacity=1.00](0.0,-0.4)--(1.0,-0.4); % (3)
  \draw[>=latex,<->,opacity=0.99](0.0,-0.6)--(1.0,-0.6); % (4)
\end{tikzpicture}
\end{document}

compile & convert to png:

pdflatex mwe.tex && convert -density 600 mwe.pdf mwe.png

MWE result:

MWE result

About the MWE:

  • You can see the problem in arrows (1) and (2), currently
  • Arrows (3) and (4) are not affected, since they have the smaller arrowheads: > = latex
  • Only commenting (2) and (4) (opacity=0.99) solves the problem for (1) - i.e. removing all transparent objects from the image.

Questions:

  • Why is this happening?
  • Is this a tikz problem or an ImageMagick problem?
  • Any solutions besides avoiding transparency or using smaller arrowheads?

Thanks

2

This is happening because these arrows consist of some draw and some fill part. You can avoid it by using a transparency group.

\documentclass[margin=0.1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
  \begin{scope}[transparency group,opacity=1.00]    
  \draw[>=Latex](0.0,-0.0)--(1.0,-0.0); % (1)
  \draw[>=latex,<->](0.0,-0.4)--(1.0,-0.4); % (3)
  \end{scope}
  \begin{scope}[transparency group,opacity=0.99]
  \draw[>=latex,<->](0.0,-0.6)--(1.0,-0.6); % (4)
  \draw[>=Latex,<->](0.0,-0.2)--(1.0,-0.2); % (2)
  \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.