5

I'm trying to create a cover page with a background image filling the entire page. On top of that in the lower third of the page should be a transparent rectangle going from side to side and on top of that, I would like to write title, author and date. I'm using tikz but having some difficulty. My code and cover page currently look like this:

\documentclass[a4paper]{article}
\usepackage{tikz}

\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center)
{\includegraphics[height=\paperheight]{example-image}};
\draw[fill=white,opacity=0.4] (-5,-24) rectangle (30,-18);
\node [scale=3.5] at (5,-20) {\sffamily\selectfont\textbf{Molecular Magnetism}};
\node [scale=2] at (5,-22) {\sffamily\selectfont\textbf{John Doe}};
\end{tikzpicture}

\end{document}

Current look of cover page

My problems are:

  1. The transparent white box goes over the edges.
  2. The title and author should both be left-aligned roughly with the big 'I' of 'Image'.

I would easily be able to solve both problems, if I knew how to

  1. make coordinates in tikz go from (0,0) at the bottom left corner of the image to (1,1) at the top right corner, and
  2. how to give tikz coordinates not with respect to the center of a node but to the bottom left corner.

Since I am using ShareLaTeX, the onimage package is not an option. Are there other ways to achieve this?

3 Answers 3

6

Since the image is scaled so that it covers the entire page, then all that is required is the width and the height of the paper to set the shift and the scale transformations. This could be done using the shift, x and y keys but I have defined a custom page cs coordinate system so that it is possible to use coordinates like (1,1) in the usual way:

\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
\tikzset{page cs/.cd, x/.store in=\px, y/.store in=\py}
\tikzdeclarecoordinatesystem{page}{%
  \tikzset{page cs/.cd, #1}% 
  \pgfpointadd{\pgfpointanchor{current page}{south west}}%
    {\pgfpoint{\px*\paperwidth}{\py*\paperheight}}%
}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center)
{\includegraphics[height=\paperheight]{example-image}};
\fill [white, opacity=0.5] (page cs:x=0,y=0) rectangle (page cs:x=1,y=1/3);
\foreach \x in {0,.125,...,1}
  \foreach \y in {0,.125,...,1}
    \fill (page cs:x=\x,y=\y) circle [radius=1/10] node[above] {\tt(\x,\y)};
\end{tikzpicture}
\end{document}

enter image description here

1
  • 2
    Just to answer my question completely, I'll mention in this comment what I found out in the meantime (which I know is really basic): You can set the anchor of a node to the corner of your choice by e.g. giving the option \node[anchor=south west].
    – Janosh
    Nov 24, 2014 at 17:51
5

I received two great answers to my question and ended using parts of both of them, which is why I thought a complete cover page template in which people just insert their background image and title information might be helpful:

\documentclass[a4paper]{article}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\begin{document}
\tikzset{page cs/.cd, x/.store in=\px, y/.store in=\py}
\tikzdeclarecoordinatesystem{page}{%
  \tikzset{page cs/.cd, #1}% 
  \pgfpointadd{\pgfpointanchor{current page}{south west}}%
    {\pgfpoint{\px*\paperwidth}{\py*\paperheight}}%
}
\thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay,font=\sffamily\bfseries\huge,inner sep=0pt,outer sep=0pt,white]

\node at (current page.center) {\includegraphics[height=\paperheight]{Images/cover2}};

\fill [NavyBlue,opacity=0.5] (page cs:x=0,y=0.075) rectangle (page cs:x=1,y=0.28);

\node [scale=2.28,anchor=west] at (page cs:x=0.075,y=0.225) {Molecular Magnetism};

\node [anchor=west] at (page cs:x=0.075,y=0.18) {A brief introduction to materials and applications};

\node [anchor=west] at (page cs:x=0.075,y=0.12) {John Doe - Cool University};

\end{tikzpicture}
\end{document}

The end result might then look something like this:

Final cover page

1
  • 3
    (+1) Thanks for showing how you combined the two answers ;). Looks a lot better with this image, too!
    – cfr
    Nov 24, 2014 at 19:37
3

This is probably not the most efficient method but I understand it ;).

The following image shows the adjusted placement together with a line of small, red circles which I used to figure out the placement. Obviously you'd delete the circles before use.

circles for placement

I've switched to a larger font with less scaling since the default fonts differ according the their size so \Huge is not just a scaled version of the normal sized font. Note that you do not need \selectfont at all. Moreover, it is a bit neater to use font= rather than putting the commands in the nodes.

(a |- b) tells TiKZ to use the point which is vertically aligned with (a) and horizontally aligned with (b). I use this in the following to align the white box with the west and east anchors of the page. I use the anchor=west key to align the text boxes from their west (left) edges.

A loop is used to place 11 small red circles and one of these is chosen to more-or-less align the text boxes' left edges with the 'I'. By varying the positions of the circles you could do this more precisely (but I'm guessing this is not your real cover image anyway!).

\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}
  [
    remember picture,
    overlay,
    font=\sffamily\bfseries\Huge,
    inner sep=0pt,
    outer sep=0pt,
  ]
  \node at (current page.center) {\includegraphics[height=\paperheight]{example-image}};
  \foreach \i in {0,1,...,10}
    {
      \path (current page.west) to coordinate [pos=\i/10] (c\i) (current page.east);
      \filldraw [red] (c\i) circle (1pt);
    }
  \draw[fill=white,opacity=0.4] (current page.west |- 0,-24) rectangle (current page.east |- 0,-18);
  \node [scale=1.5, anchor=west] at (c1 |- 0,-20) {Molecular Magnetism};
  \node [anchor=west] at (c1 |- 0,-22) {John Doe};
\end{tikzpicture}

\end{document}
2
  • Those are some great tips. Thanks for cleaning up my code. I already used Mark's positioning approach but I incorporated every other aspect of your solution.
    – Janosh
    Nov 24, 2014 at 18:21
  • By the way, how did you guess this isn't my real cover image? (Just kidding.) Since I ended up combining code from your answer and Mark's, I'll add another answer in which I post my real title page and the code so other people with this problem can see what the end result is going to look like.
    – Janosh
    Nov 24, 2014 at 18:26

You must log in to answer this question.

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