10

I need some help with a titlepage for tikz

I want to create the following... 3 red lines, a gray space a green space but I already fail with just creating a line across the whole page...

\draw (0,0) -- (\pagewidth,0) fails :-(, it only creates a line of 2 cm or so...

I hope anyone is good with tikz and can create this for me.

reference image

Update

@Tobi I now have the following:

\documentclass{report}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{
  calc,
  positioning
}
\begin{document}
\begin{titlepage}
\begin{tikzpicture}[overlay,remember picture]
  \coordinate (SW) at (current page.south west);
  \coordinate (SE) at (current page.south east);
  \coordinate (NW) at (current page.north west);
  \coordinate (NE) at (current page.north east);

  % commented out because it is not necessary to compile, 
  % but one should note that the background is here, 
  % because of overlapping parts.
  %\node at ($(current page.south west)$){
  %  \begin{tikzpicture}[overlay]
  %    %\includegraphics[width=\paperwidth]{./figures/cover_spaceshuttle.jpg}
  %  \end{tikzpicture}};  

  \fill[blue,very nearly opaque] ($(SW)!0.2!(SE)$) -| ($(SE)!1.95!(NE)$) -- cycle;
  \fill[red,very nearly opaque] ($(SW)!0.2!(SE)$) -| ($(SE)!1.95!(NE)$) -- cycle;
  \draw[white,fill] ($(SW)$) rectangle ($(SE)!0.1!(NE)$);
  \fill[blue,very nearly opaque] ($(SW)!0.2!(SE)$) -| ($(SE)!1.95!(NE)$) -- cycle;
  \draw[red] ($(SW)!0.20!(SE)$) -- ($(NW)!0.61!(NE)$);
  \draw[red] ($(SW)!0.10!(NW)$) -- ($(SE)!0.10!(NE)$);
  \node at ($(SW)!0.1!(NW)$) [
    anchor=north,
    xshift=6.40cm,
    yshift=0.13cm,
    minimum width=\paperwidth,
    align=center,
    outer sep=0pt,
    font=\sffamily]{something};
\end{tikzpicture}
\end{titlepage}
\end{document}

This code generates the following page Current situation and prefered situation

Now the blue fill fills all the way to the top, on the left side. But I only want to let it fill at about $(SW)!0.05!(NW)$, the right side. How do I achieve this? Thanks in advance

2
  • See texample.net/tikz/examples/exam-sheet for an example Jun 13, 2012 at 8:31
  • The easiest way to limit the blue part it to clip it. Try \begin{scope}\clip (SW) rectangle ($(SE)!0.05!(NE)$);\fill[blue,very nearly opaque] ($(SW)!0.2!(SE)$) -| ($(SE)!1.95!(NE)$) -- cycle;\end{scope}. But I’m not sure if I get you right.
    – Tobi
    Jun 13, 2012 at 18:33

1 Answer 1

13

Use the options overlay and remember picture to make the cooridnates of the current page available as the current page node.

Try to adapt this to fit your needs …

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc,positioning}% [0]

\begin{document}
\begin{titlepage}
\begin{tikzpicture}[overlay,remember picture,line width=5pt]
    % set a new origin [1]
    \coordinate (O) at (current page.south west);
    % gray triangle
    \fill [gray] (current page.south west) -| (current page.north east) -- cycle;
    % red line
    \draw [red] (current page.south west) -- (current page.north east);
    % white framed box
    \node at (current page.south) [%
        draw=red,
        inner sep=15pt,
        fill=white,
        above=5cm,
        font=\sffamily\bfseries\Huge
    ] {The book title};
    % red box at 0.8\pageheight
    \node (Author) at ($(O)+(0,0.8\paperheight)$) [% [2] [4]
        fill=red,
        anchor=south west,
        minimum width=\paperwidth,
        align=center,
        outer sep=0pt,
        font=\sffamily\bfseries] {Jon Doe};
    % red box at 0.75\paperheight
    \node at ($(current page.south)!0.75!(current page.north)$) [% [3]
        fill=red,
        anchor=south,
        minimum width=\paperwidth,
        align=center,
        outer sep=0pt,
        font=\sffamily] {\today};
    % red box above the author
    \node [%
        fill=red,
        above=1mm of Author,% [5]
        minimum width=\paperwidth,
        align=center,
        outer sep=0pt,
        font=\sffamily] {\TeX.SX example press};
\end{tikzpicture}
\end{titlepage}
\end{document}

title page

(Compile twice to get the right result)

Update
I added three more ways to position your elements on the page

  • Set a new origin coordinate (O) to the lower left corner 1 of the page and move relatively [2] to it (needs calc library [0]).
  • Use TikZ to calculate the position using the (point)!div!(point) syntax [3] (needs calc library [0]).
  • Name a node [4] and position a second node relatively to it [5] (needs positioning library [0]).
9
  • Thanks Tobi for your comment. Now for example I want to draw a line at 0.2*pageheight from right to left... How do I do that? It's kinda hard when using current page.center or those kind of coordinates... I would rather use something like 0.2*\pageheight Which I actually tried with using > \coordinate (front) at (0,0); > \coordinate (horizon) at (0,.31\paperheight); > \coordinate (bottom) at (0,-.6\paperheight); > \coordinate (sky) at (0,.57\paperheight); > \coordinate (left) at (-.51\paperwidth,0); > \coordinate (right) at (.51\paperwidth,0);
    – WG-
    Jun 13, 2012 at 8:48
  • This was my code, it compiles correctly but no line is drawn... can it because I use the geometry package? \begin{tikzpicture}[overlay,remember picture] \coordinate (left) at (-.51\paperwidth,.31\paperheight); \coordinate (right) at (.51\paperwidth,.31\paperheight); \draw[blue] (left) -- (right); \end{tikzpicture}
    – WG-
    Jun 13, 2012 at 8:55
  • @Wouter If you can include your minimal example(starting from \documentclass to \end{document} with only relevant packages and the relevant part of the code) we can help you better instead of these iterations.
    – percusse
    Jun 13, 2012 at 8:59
  • @Wouter Try \fill[red] (0,0) circle (8pt); inside Tobi's example to understand your problem. It's more easy to use relativ coordinates with "current page" anchors ! Jun 13, 2012 at 9:01
  • @Wouter: See my update …
    – Tobi
    Jun 13, 2012 at 9:45

You must log in to answer this question.

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