0

In https://tex.stackexchange.com/a/382726/240454, the author claims that the background of tikzpictures are transparent by default.

In this MWE, for me, using either pdflatex or xelatex, I remain with a white background. Is there a problem with my installation?

\documentclass[crop,multi=tikzpicture,varwidth=false,border=1cm]{standalone}
\usepackage{tikz}

\begin{document} \begin{tikzpicture} \draw[red,line width=1mm,fill=blue] (-1,-1) -- (-1,1) -- (1,1) -- cycle; \end{tikzpicture} \end{document}

Compiled using

xelatex.exe -synctex=1 -interaction=nonstopmode "test".tex

The result is then, after exporting the pdf as png using Adobe Acrobat Pro DC:

  • 4
    The PDF generated by the above code should have no background and if you import this PDF into some other document and place it over another picture, there should be no white background visible. However, Acrobat (as well as most other PDF viewers) will always show a white background. You can disable this in Acrobat by checking File > Preferences > Page Display > Show transparency grid. – Jasper Habicht Oct 07 '21 at 08:53
  • Thank you very much for this option in my Acrobat settings! – XGDragon Oct 07 '21 at 10:22

1 Answers1

1

PDF's can and will have transparency since PDF 1.4. https://en.wikipedia.org/wiki/PDF#Transparency

Your code generates a PDF with transparent background(Correction: No background). Apparently, your export settings of Adobe Acrobat makes your PNG white.

I compile your code, and use:

convert triangle.pdf triangle.png

to create this PNG:

Window showing a triangle.png with transparent background

(Here shown viewed in Mac preview)

convert is from ImageMagick: https://imagemagick.org (free for all platforms)