3

I want to display a vertical line in the middle of my document. For creating the line I use tikz and for adjusting a margin I use adjustbox.

\documentclass[a4paper,12pt]{article}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{noto-sans}
\renewcommand{\familydefault}{\sfdefault}

\usepackage{geometry}
\geometry{
a4paper,
lmargin=0mm,
rmargin=0mm,
tmargin=0mm,
bmargin=0mm,
}

\usepackage{showframe}

\usepackage{adjustbox}


\setlength{\parindent}{0cm}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]

\adjustbox{margin*=0cm 1cm 1cm 0cm}{ 
    \fill[black] (current page.north) rectangle ([xshift=0.1cm]current page.south);
}

\end{tikzpicture}
\end{document}

Unfortunately, the margin is either applied to the bottom OR to the top. But not both.

Regards Andi

5
  • Does the margin mean that the line starts one cm below the top and ends one cm above the bottom? If so, just do \draw[line width=1mm] ([yshift=-1cm]current page.north) -- ([yshift=1cm]current page.south);.
    – user121799
    May 27, 2018 at 20:33
  • @marmot Thank you very much! Thats exactly what I wanted.
    – AndiLeni
    May 27, 2018 at 20:49
  • Also, adding \adjustbox inside a tikzpicture does not work as indented. You need to apply it around it. Dec 29, 2018 at 8:46
  • @marmot: Please post your comment as an answer, so that AndiLeni can accept it to conclude the question. Dec 29, 2018 at 8:47
  • @MartinScharrer Done, thanks for pinging me.
    – user121799
    Dec 29, 2018 at 9:09

2 Answers 2

1

From my above comment.

\documentclass[a4paper,12pt]{article}

\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{noto-sans}
\renewcommand{\familydefault}{\sfdefault}

\usepackage{geometry}
\geometry{
a4paper,
lmargin=0mm,
rmargin=0mm,
tmargin=0mm,
bmargin=0mm,
}

\usepackage{showframe}


\setlength{\parindent}{0cm}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\draw[line width=1mm] ([yshift=-1cm]current page.north) -- ([yshift=1cm]current page.south);
\end{tikzpicture}
\end{document}

enter image description here

1
  • Please add the comment text into your answer (maybe modified a little), so that the answer is selfcontaining. Dec 29, 2018 at 9:14
2

I think this task is easier with eso-pic:

\documentclass[a4paper,12pt]{article}

\usepackage{eso-pic}

\AddToShipoutPicture{
    \thicklines
    \setlength\unitlength{1mm}
    \AtPageCenter{\line(0,1){138.5}}
    \AtPageCenter{\line(0,-1){138.5}}
    }

\pagestyle{empty}
\begin{document}    
\null
\end{document}

enter image description here

Note: magic number 138.5mm is half of A4 paper height (297mm) minus 1cm for top and bottom margins.

You must log in to answer this question.

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