Tikz 问题:从左上角开始的图片正好

Tikz 问题:从左上角开始的图片正好

我正在编写一个python脚本,用于生成一个latex文件艾弗里 3668标签。我使用 tikz 包执行此操作(每个标签都是一个节点)。我的问题是节点不在工作表的标签中居中(avery 工作表上没有边距)。我的意思是:

在此处输入图片描述

问题实际上是我的 tikzpicture 并非恰好从工作表的左上角开始。您如何修复它?

这是乳胶代码:

\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}

在此先感谢您的帮助 !

答案1

该包pgfornament加载了包tikz因此\usepackage{tikz}被删除。

使用和 的循环\foreach来放置所有节点。这样, 的代码\node只需要输入一次。

在此处输入图片描述

\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}

相关内容