2

I'm using the below Latex code to draw a tikzpicture

\documentclass[convert={density=300,size=1080x800,outext=.png},tikz, border=1cm]{standalone}
\usepackage{{xcolor}}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}

    \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont, label={[yshift=-6cm,style={font=\fontsize{100}{100} } ] {$x_9$} } ] at (25, 20) {1};
    \draw [line width=0.1cm](25,22.0) -- (25,24.0);
    \draw [line width=0.12cm] (25,25.0) circle (1);
    \draw [line width=0.12cm](25,24.0) -- (25,26.0);
    \draw [line width=0.12cm](24,25.0) -- (26,25.0);
    \draw [arrows={-Triangle[angle=90:0.5cm,black,fill=black,line width=0.1cm]}](26,25.0) -- (25.9999,25.0);

\end{tikzpicture}
\end{document}

The file is compiled with pdflatex -shell-escape file.tex and produces the below png.

enter image description here

Although it can't be seen here, the png has a transparent background ( you can see it with only viewing the image link). I want it to have a white background directly instead of converting with an additional external tool.

How can we have a white background or any color at once?

5

You can use the backgrounds library. Notice that this solution assumes that you do not use the background layer for other purposes, if you do, you may have to introduce other layers and order them appropriately.

\documentclass[convert={density=300,size=1080x800,outext=.png},tikz, border=1cm]{standalone}
\usetikzlibrary{arrows.meta,backgrounds}
\tikzset{white background/.style={show background rectangle,tight background,
background rectangle/.style={fill=white}}}
\begin{document}
\begin{tikzpicture}[white background]

    \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont, label={[yshift=-6cm,style={font=\fontsize{100}{100} } ] {$x_9$} } ] at (25, 20) {1};
    \draw [line width=0.1cm](25,22.0) -- (25,24.0);
    \draw [line width=0.12cm] (25,25.0) circle (1);
    \draw [line width=0.12cm](25,24.0) -- (25,26.0);
    \draw [line width=0.12cm](24,25.0) -- (26,25.0);
    \draw [arrows={-Triangle[angle=90:0.5cm,black,fill=black,line width=0.1cm]}](26,25.0) -- (25.9999,25.0);

\end{tikzpicture}
\end{document}
2

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.