Outils pour utilisateurs

Outils du site


pele_mele:stack_exchange:tex-374734

Why is there a padding only on the first row of a repeating pattern?

I've made a page of labels and I don't understand why the first line is rendered in a different way as the others.

The first line is not align the same way and the \vspace* following it doesn't have the expected effect.

Here is my code:

\documentclass{article}
 
\usepackage[a4paper,margin=1cm,landscape]{geometry}
\usepackage{pgfornament}
\usetikzlibrary{calc}
 
\newcommand\myLabel{
    \begin{tikzpicture}
        % Text
        \node[font=\fontsize{32}{35}\selectfont,align=center,text width=11cm](myLabel) {\myTitle};
 
        % Outside of the label
        \draw[line width=1pt,line cap=rect,lightgray] ([xshift=-10pt,yshift=10pt]myLabel.north west) -| ([xshift=10pt,yshift=-10pt]myLabel.south east) -| ([xshift=-10pt,yshift=-10pt]myLabel.north west) -- cycle;
 
        % Decoration
        \draw[line width=1pt,line cap=rect,lightgray] (myLabel.north west) -| (myLabel.south east) -| (myLabel.north west) -- cycle;
 
        % Decoration in corners
        \node[anchor=north west,font=\color{gray}] at ([xshift=-10pt,yshift=10pt]myLabel.north west){\pgfornament[width=1cm]{31}};
        \node[anchor=north east,font=\color{gray}] at ([xshift=10pt,yshift=10pt]myLabel.north east){\pgfornament[width=1cm,symmetry=v]{31}};
        \node[anchor=south west,font=\color{gray}] at ([xshift=-10pt,yshift=-10pt]myLabel.south west){\pgfornament[width=1cm,symmetry=h]{31}};
        \node[anchor=south east,font=\color{gray}] at ([xshift=10pt,yshift=-10pt]myLabel.south east){\pgfornament[width=1cm,symmetry=c]{31}};
 
    \end{tikzpicture}
}
 
\begin{document}
    \pagenumbering{gobble}
    \def \myTitle {my label content}
    \myLabel \myLabel \\
    \vspace*{4mm}
    \myLabel \myLabel \\
    \vspace*{4mm}
    \myLabel \myLabel \\
    \vspace*{4mm}
    \myLabel \myLabel \\
    \vspace*{4mm}
    \myLabel \myLabel \\
    \vspace*{4mm}
    \myLabel \myLabel \\
    \vspace*{4mm}
    \myLabel \myLabel \\
    \vspace*{4mm}
    \myLabel \myLabel \\
    \vspace*{4mm}
\end{document}

The horizontal misalignment was due to first line being indented. To fix the issue with the vertical space: don't use \\ if you want a line break.

\documentclass{article}
 
\usepackage[a4paper,margin=1cm,landscape]{geometry}
\usepackage{pgfornament}
\usetikzlibrary{calc}
 
\newcommand\myLabel{%
    \begin{tikzpicture}
        % Text
        \node[font=\fontsize{32}{35}\selectfont,align=center,text width=11cm](myLabel) {\myTitle};%
        % Outside of the label
        \draw[line width=1pt,line cap=rect,lightgray] ([xshift=-10pt,yshift=10pt]myLabel.north west) -| ([xshift=10pt,yshift=-10pt]myLabel.south east) -| ([xshift=-10pt,yshift=-10pt]myLabel.north west) -- cycle;%
        % Decoration
        \draw[line width=1pt,line cap=rect,lightgray] (myLabel.north west) -| (myLabel.south east) -| (myLabel.north west) -- cycle;%
        % Decoration in corners
        \node[anchor=north west,font=\color{gray}] at ([xshift=-10pt,yshift=10pt]myLabel.north west){\pgfornament[width=1cm]{31}};%
        \node[anchor=north east,font=\color{gray}] at ([xshift=10pt,yshift=10pt]myLabel.north east){\pgfornament[width=1cm,symmetry=v]{31}};%
        \node[anchor=south west,font=\color{gray}] at ([xshift=-10pt,yshift=-10pt]myLabel.south west){\pgfornament[width=1cm,symmetry=h]{31}};%
        \node[anchor=south east,font=\color{gray}] at ([xshift=10pt,yshift=-10pt]myLabel.south east){\pgfornament[width=1cm,symmetry=c]{31}};%
    \end{tikzpicture}%
}
 
\setlength\parindent{0cm}
 
\begin{document}
    \pagenumbering{gobble}%
    \def\myTitle{my label content}%
        \myLabel \myLabel 
 
    \vspace*{4mm}
    \myLabel \myLabel 
 
    \vspace*{4mm}
    \myLabel \myLabel 
 
    \vspace*{4mm}
    \myLabel \myLabel 
 
    \vspace*{4mm}
    \myLabel \myLabel 
 
    \vspace*{4mm}
    \myLabel \myLabel 
 
    \vspace*{4mm}
    \myLabel \myLabel 
 
    \vspace*{4mm}
    \myLabel \myLabel 
 
    \vspace*{4mm}
\end{document}

pele_mele/stack_exchange/tex-374734.txt · Dernière modification : 2020/11/18 10:38 de alexis