I an currently formatting a page with the tikz
package. I created a command to insert a vertical line and text above it. Sadly the formatting seems to be different every time it is called (there are spaces where no spaces are declared).
What's going on there?
My code:
% !TeX program = lualatex
\documentclass[a4paper,12pt]{article}
%font encoding & formatting
\usepackage[onehalfspacing]{setspace}
\usepackage{fontspec}
\setmainfont{Arial}
\usepackage[document]{ragged2e}
%language
\usepackage[ngerman]{babel}
\usepackage{lipsum}
%Styles
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usepackage{atbegshi}
\usepackage{fancyhdr}
\usepackage{xcolor}
\definecolor{bluey}{RGB}{12,3,150}
\newcommand{\sep}[1]{
\vspace{0.5cm}
{\color{blue} \large \textbf{#1}}\\
\begin{tikzpicture}
\draw [blue, fill=blue] (-2,0.5) circle [radius=0.17];
\draw [blue, line width = 1.5pt] (-1.75,0.5) -- (2.5,0.5);
\draw [lightgray, line width = 1.5pt] (2.5,0.5) -- (11,0.5);
\end{tikzpicture}
}
%header format
\newcommand\HeaderTwo{%
\begin{tikzpicture}[remember picture,overlay]
\fill[bluey]
(current page.north west) -- (current page.north east) --
([yshift=2cm]current page.north east|-current page text area.north east) --
([yshift=3cm]current page.north west|-current page text area.north west) -- cycle;
\end{tikzpicture}%
}
\begin{document}
\HeaderTwo
\sep{My very very long foo Text}
\vspace{0.5cm}
\lipsum[1]
\sep{Another very very long foo text}
\vspace{0.5cm}
\lipsum[2]
\clearpage
\HeaderTwo
\sep{Another very very long foo text}
\vspace{0.5cm}
\lipsum[3]
\end{document}
\HeaderTwo
at the beginning of the page. This makes the\vspace
visible as latex thinks you have started the page already. You should probably use it as header and won't have any issues anymore.Headertwo
definition and yoursep
. The line width is unaffected, that is probably an aliasing problem with your screen. Zoom in (or print) to see constant line width.\headheight
for a 12pt doc and added a\par
I forgot in\HeaderTwo
.