1

I am wrinting a python script that makes a latex file for avery 3668 labels. I do this with the tikz package (each label is a node). My problem is that the nodes are not centered in the labels of the sheet (there is no margin on the avery sheet). Here is what I mean :

enter image description here

The problem is actually that my tikzpicture doesn't begin at the top left of my sheet exactly. How would you fix it ?

Here's the latex code :

\documentclass[a4paper, 10pt]{article}

\usepackage{geometry}
\geometry{hmargin=0cm,vmargin=0cm}
\usepackage{tikz}
\usepackage{pgfornament}

\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}
\node [anchor=north west, inner sep=0pt] at (current page.north west) {
\begin{tikzpicture}[every node/.append style = {anchor=center}]
\node [text width=0.5cm, align=left, anchor=north, color=white] at (0, 0) {+};\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (5.25, -8.839285714285714) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (10.5, -8.839285714285714) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (15.75, -8.839285714285714) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (0.0, -10.960714285714285) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (5.25, -10.960714285714285) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (10.5, -10.960714285714285) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (15.75, -10.960714285714285) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (0.0, -13.082142857142856) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (5.25, -13.082142857142856) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (10.5, -13.082142857142856) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (15.75, -13.082142857142856) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (0.0, -15.203571428571427) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (5.25, -15.203571428571427) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (10.5, -15.203571428571427) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (15.75, -15.203571428571427) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\node [draw,align=center, inner sep=6pt, double, font=\itshape,text width=4.25cm, anchor=north] at (0.0, -17.325) {Rhubarbe\\ \vspace{-0.15cm}\pgfornament[width=1cm]{80}\vspace{0.075cm}\\10 février 2024};
\end{tikzpicture}};
\end{tikzpicture}
\end{document}

Thanks in advance for your help !

2
  • 3
    I don't know if it's relevant, but nesting tikzpictures is generally not recommended, I believe. Instead you could place all the nodes relative to current page.north west directly, e.g. with \path (current page.north west) ++(x,y) node ... Commented Feb 10 at 10:06
  • I tried it but it doesn't work... Commented Feb 10 at 10:41

1 Answer 1

2

The package pgfornament loads the package tikz so \usepackage{tikz} was removed.

Loops with \foreach are used to place all nodes. In this way, the code for the \node only needs to be typed once.

enter image description here

\documentclass[a4paper]{article}
\usepackage[a4paper,left=0cm,right=0cm]{geometry}
\usepackage{pgfornament}
\begin{document}
\thispagestyle{empty}
\centering%
\begin{tikzpicture}
\foreach\x in {1,...,4}{
  \foreach\y in {1,...,5}{
    \node[
      draw,
      align=center,
      inner sep=6pt,
      double,
      font=\em,
      text width=4.25cm
    ]
    at ({\paperwidth*\x/4},{2.1cm*\y})
    {Rhubarbe\\[-0.15cm]
    \pgfornament[width=1cm]{80}\\[0.075cm]
    10 février 2024};
  }
}
\end{tikzpicture}
\end{document}
1
  • Thank you for your good answer ! I didn't thought to use the \centering command. Commented Feb 10 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .