1

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}
A.D.
  • 285

1 Answers1

2

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}

enter image description here

  • It works well. Great! I am also wondering the reason behind the comment signs ending lines? – A.D. Jun 13 '17 at 17:10
  • @A.D. Not all of them are necessary, for debugging I wanted to better be safe than sorry. For some explanation, see https://tex.stackexchange.com/questions/7453/what-is-the-use-of-percent-signs-at-the-end-of-lines – samcarter_is_at_topanswers.xyz Jun 13 '17 at 17:13