3

This question already has an answer here:

I want to create/draw a front page of a document and therefore I want to draw a line from one corner of the Page to another. Ok in the final version I want to implement some control points. But up until now I can´t get the drawing to work when I use "page coordinates" instead of points...

\documentclass{article}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{tikz,xcolor}

\usetikzlibrary{shadows}    

\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay]
    \coordinate (A) at (current page.north east, current page.north east);
    \coordinate (B) at (current page.north, current page.south);
    \draw[line width=1.5pt]%, cap=round]
    (A) -- (B)
\end{tikzpicture}

\end{document}

marked as duplicate by zeroth, Mico, Andrew, Jesse, Andrew Swann Aug 28 '15 at 13:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Welcome! You are missing a final semicolon after the (A) -- (B). – cfr Aug 28 '15 at 11:15
  • 1
    Also (current page.north east, current page.north east) does not make sense, It is sort of like ((a,b),(c,d) (current page.north east) is a coordinate on the page – daleif Aug 28 '15 at 11:17
  • Note that if you want to print this you should enlarge the page by about 3mm to prevent problems with the tolerance at cutting the pages … see en.wikipedia.org/wiki/Bleed_(printing) – Tobi Aug 28 '15 at 11:33
6

This works just fine. You had the coordinates wrong and a missing ;. I've removed a few packages that are not relevant for the mwe

\documentclass{article}
\usepackage{tikz,xcolor}
\begin{document}
 \thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay]
    \coordinate (A) at (current page.north west);
    \coordinate (B) at (current page.south east);
    \draw[red, very thick]%, cap=round]
    (A) -- (B);
\end{tikzpicture}

Test


\end{document}
3

It isn't entirely clear which line you are trying to draw: a line from the left to right of the page? a diagonal? (which one?)

This example uses colours to distinguish four possibilities:

4 lines

\documentclass{article}
\usepackage{tikz}
\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay]
    \coordinate (A) at (current page.north west);
    \coordinate (B) at (current page.south east);
    \draw[line width=1.5pt, cap=round, red]
    (A) -- (B);
    \draw[line width=1.5pt, cap=round, blue]
    ([yshift=-15pt]current page.north west) -- ([yshift=-15pt]current page.north east);
    \draw[line width=1.5pt, cap=round, green]
    ([yshift=15pt]current page.south west) -- ([yshift=15pt]current page.south east);
    \draw[line width=1.5pt, cap=round, magenta]
    (current page.south west) -- (current page.north east);
\end{tikzpicture}

\end{document}

The errors were likely caused by the two problems identified in comments:

  1. The final \draw command must end in a terminating semicolon.
  2. (current page.north,current page.north) is not a location. It confuses the (<x>,<y>) syntax with the (<named coordinate>) syntax. If you need something like this, you can say (<named coordinate 1> -| <named coordinate 2>) which will use the x bit of <named coordinate 1> and the y bit of <named coordinate 2>. In the case of the current page coordinates there isn't much point because the relevant points are all defined anyway.

However, for purposes of demonstration:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay]
     \draw[line width=1.5pt]
    (current page.south west) .. controls (10,-10) .. (current page.north -| current page.east);
\end{tikzpicture}

\end{document}

curved

Not the answer you're looking for? Browse other questions tagged or ask your own question.