Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Using TiKZ, I'm trying to create an image that fits the margin of odd-sided pages (a water stamp of sort) for an A6 booklet. My idea was at first to create an image that is exactly the same size as an A6 page, compile to PDF and then use eso-pic to set it as the background of the booklet document.

However, I've realized I want to use commands such as \thesection to show information in the margin, so I'd rather do this in a way where everything fits in the same document. An example of what I want to accomplish can be seen here, where the document shows an A4 with eight A6 pages, the first one being odd-numbered.

I can't figure out how to scale the tikzpicture to fit the page exactly. Some parts of the image should be fitted to the page edge, so I need it to scale exactly, without margins. You could say I'm trying to do this, only the opposite.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

How about this, it makes use of Martin Scharrer's answer in this answer:

\documentclass[10pt]{scrartcl}
\usepackage[margin=20mm,a6paper]{geometry}
\usepackage{tikz}
\usepackage{xifthen}
\usetikzlibrary{fit,calc}
\usepackage{lipsum}
\usepackage{everypage}

\parindent0mm

\newcommand{\currentsidemargin}{%
  \ifodd\value{page}%
    \oddsidemargin%
  \else%
    \evensidemargin%
  \fi%
}

\AddEverypageHook{%
\ifthenelse{\isodd{\thepage}}
{   \begin{tikzpicture}[overlay, remember picture]
        \path (current page.north west) ++(\hoffset, -\voffset) node[anchor=north west, shape=rectangle, inner sep=0, minimum width=\paperwidth, minimum height=\paperheight] (pagearea) {};
        \path (pagearea.north west) ++(1in+\currentsidemargin,-1in-\topmargin-\headheight-\headsep) node[anchor=north west, shape=rectangle, inner sep=0, minimum width=\textwidth, minimum height=\textheight] (textarea) {};
        \node[inner sep=0,fit=(pagearea.north east)(textarea.north east)(pagearea.south east)] (marginbox) {};
        \draw (marginbox.south east) rectangle (marginbox.north west);
        \draw (marginbox.south east) -- (marginbox.north west);
    \end{tikzpicture}
}{}
}

\begin{document}

\lipsum[1-10]

\end{document}

enter image description here

share|improve this answer
    
This is fantastic! Will be tried out immediately! =) –  Tomas Lycken Jun 28 '12 at 22:01
    
I was able to modify this to suit my needs perfectly. The key to success was nesting tikzpictures, with the node anchored to current page.north east. Thanks a lot! –  Tomas Lycken Jun 28 '12 at 23:29
add comment

I don't exactly understand the question but you can produce your pages rather bluntly and then combine them via for example Can I convert a 16 page pdf into an 8x2 matrix in LaTeX?

For the multiple page file you can use something like

\documentclass{article}
\usepackage[paperheight=148mm,paperwidth=105mm]{geometry}
\usepackage{tikz,lipsum}

\begin{document}
\thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay]
    \draw[line width=5mm,red!20] 
    ([shift={(-0.5\pgflinewidth,-0.5\pgflinewidth)}]current page.north east) 
    rectangle 
    ([shift={(0.5\pgflinewidth,0.5\pgflinewidth)}]current page.south west);
    \node[scale=3,opacity=0.2,rotate=60] at (current page.center) {\textsf{First Watermark}};
\end{tikzpicture}
\lipsum[2]
\newpage
\thispagestyle{empty}

\begin{tikzpicture}[remember picture,overlay]
    \draw[line width=5mm,blue!20] 
    ([shift={(-0.5\pgflinewidth,-0.5\pgflinewidth)}]current page.north east) 
    rectangle 
    ([shift={(0.5\pgflinewidth,0.5\pgflinewidth)}]current page.south west);
\end{tikzpicture}
\lipsum[3]
\end{document}

Note that you have to run twice for remember picture,overlay to work properly.

enter image description here

EDIT Only for the side of the page,

\documentclass{article}
\usepackage[paperheight=148mm,paperwidth=105mm]{geometry}
\usepackage{tikz,lipsum}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
    \draw[line width=5mm,blue!20] 
    ([shift={(-0.5\pgflinewidth,\pgflinewidth)}]current page.north east) 
    --
    ([shift={(-0.5\pgflinewidth,0)}]current page.south east) node[circle,anchor=east,pos=0.2,fill,draw,text=black] {\Large $\Gamma$};
\end{tikzpicture}
\lipsum[3]
\end{document}

enter image description here

share|improve this answer
    
This is great, but it doesn't really answer to my main problem: how to fit the watermark to the edge of the page. Whatever I try, the picture is just enlarged to the left instead of moved to the right... –  Tomas Lycken Jun 28 '12 at 19:08
    
Those rectangles are also watermarks. You can use the (current page) node to position your picture. Can you provide more details about the watermark even make a compilable example so that we can have a look at the positioning? –  percusse Jun 28 '12 at 19:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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