0

I'm currently developing an LFSR drawing library that the latex is output from Python code. One main issue that has been left is the border.

\documentclass[convert={density=300,size=1080x800,outext=.png},tikz, border={15mm 15mm 15mm 15mm}]{standalone}
\usepackage{xcolor}
\usetikzlibrary{arrows.meta,backgrounds}
\tikzset{{white background/.style={{show background rectangle,tight background,background rectangle/.style={{fill=white}} }} }}

\begin{document} \begin{tikzpicture}[white background]

%node 5 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (25, 20) {}; \draw line width=0.1cm -- (25,24.0); \draw [line width=0.12cm] (25,25.0) circle (1); \draw line width=0.12cm -- (25,26.0); \draw line width=0.12cm -- (26,25.0); \draw arrows={-Triangle[angle=90:0.5cm,black,fill=black,line width=0.1cm]} -- (25.9999,25.0); %node 4 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (29, 20) {}; %node 3 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (33, 20) {}; %node 2 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (37, 20) {}; \draw line width=0.1cm -- (37,24.0); \draw [line width=0.12cm] (37,25.0) circle (1); \draw line width=0.12cm -- (37,26.0); \draw line width=0.12cm -- (38,25.0); \draw arrows={-Triangle[angle=90:0.5cm,black,fill=black,line width=0.1cm]} -- (37.9999,25.0); %node 1 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (41, 20) {}; %node 0 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (45, 20) {}; \draw line width=0.1cm -- (45,25.0); \draw[->,line width=0.1cm,arrows={-Triangle[angle=90:0.5cm,black,fill=black,line width=0.1cm]}] (45,25.0) -- (17,25.0) -- (17,20) -- (23.0,20); \draw[->,line width=0.1cm,arrows={-Triangle[angle=90:0.5cm,black,fill=black,line width=0.1cm]},font=\fontsize{100}{100}\selectfont] (47.0,20) -- (53,20) node[midway,above]{};

\end{tikzpicture} \end{document}

And the output PNG is

enter image description here

The border parameter doesn't work, or at least I don't know how to work it correctly. I've seen a problem and the solution doesn't work for me.

How can I make a border out of the drawing?

kelalaka
  • 395
  • What do you mean by work? It worked for me, changing only the color of the background to make the border visible. If your goal is to extend the background color, don't use border. Just increase the (current bounding box) in the tikzpicture. – John Kormylo May 07 '21 at 20:41
  • @JohnKormylo Unfortunately, the only viewers that I've tested don't show the transparent border. When I see the answer, I've looked with the gimp. Viola. It is simple to miss, right. Any link for the bounded box? – kelalaka May 07 '21 at 20:45

2 Answers2

2

It is working indeed. Your picture has a border, but it is transparent. You can check it by opening the picture in other tab, or by inspecting the pdf file.

You must remove the alpha channel if you want fill the tranparency with a specific color (you can do it by passing options background and flatten to convert command):

\documentclass[convert={command=\unexpanded{{convert -density 300 \infile\space -resize 1080x800 -background red -flatten \outfile}},outext=.png,},tikz, border={15mm 15mm 15mm 15mm}]{standalone}
\usepackage{xcolor}
\usetikzlibrary{arrows.meta,backgrounds}
\tikzset{{white background/.style={{show background rectangle,tight background,background rectangle/.style={{fill=yellow}} }} }}

\begin{document} \begin{tikzpicture}[white background]

...

\end{tikzpicture} \end{document}

enter image description here

Change red in the first line by your favorite color.

1

This will add a 15mm border inside the tikzpicture (at end of code).

\documentclass[convert={density=300,size=1080x800,outext=.png},tikz]{standalone}
\usepackage{xcolor}
\usetikzlibrary{arrows.meta,backgrounds}
\tikzset{{white background/.style={{show background rectangle,tight background,background rectangle/.style={{fill=lightgray}} }} }}

\begin{document} \begin{tikzpicture}[white background]

%node 5 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (25, 20) {}; \draw line width=0.1cm -- (25,24.0); \draw [line width=0.12cm] (25,25.0) circle (1); \draw line width=0.12cm -- (25,26.0); \draw line width=0.12cm -- (26,25.0); \draw arrows={-Triangle[angle=90:0.5cm,black,fill=black,line width=0.1cm]} -- (25.9999,25.0); %node 4 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (29, 20) {}; %node 3 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (33, 20) {}; %node 2 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (37, 20) {}; \draw line width=0.1cm -- (37,24.0); \draw [line width=0.12cm] (37,25.0) circle (1); \draw line width=0.12cm -- (37,26.0); \draw line width=0.12cm -- (38,25.0); \draw arrows={-Triangle[angle=90:0.5cm,black,fill=black,line width=0.1cm]} -- (37.9999,25.0); %node 1 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (41, 20) {}; %node 0 \draw node[draw, fill={{rgb:black,1;white,5}}, minimum size=4cm,line width=0.1cm,font=\fontsize{100}{100}\selectfont] at (45, 20) {}; \draw line width=0.1cm -- (45,25.0); \draw[->,line width=0.1cm,arrows={-Triangle[angle=90:0.5cm,black,fill=black,line width=0.1cm]}] (45,25.0) -- (17,25.0) -- (17,20) -- (23.0,20); \draw[->,line width=0.1cm,arrows={-Triangle[angle=90:0.5cm,black,fill=black,line width=0.1cm]},font=\fontsize{100}{100}\selectfont] (47.0,20) -- (53,20) node[midway,above]{};

\path (current bounding box.north east) +(15mm,15mm) (current bounding box.south west) +(-15mm,-15mm); \end{tikzpicture} \end{document}


Result:

enter image description here

kelalaka
  • 395
John Kormylo
  • 79,712
  • 3
  • 50
  • 120