8

I've got a LaTeX document, and I've been given a PNG file consisting of a page border with a big transparent section in the middle.

Is it possible to use LaTeX to add that image to every page, with the actual content in the transparent section; or will I have to create the PDF with LaTeX and then manually add the border in some other way?

1 Answer 1

8

One option would be to use the background package to place the image as a background image; the geometry package can be used to adjust the text area. A little example:

\documentclass{article}
\usepackage[tmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm,bmargin=2.5cm]{geometry}
\usepackage{graphicx}
\usepackage{background}
\usepackage{fourier}
\usepackage{lipsum}

\backgroundsetup{scale=1,angle=0,opacity=1,contents={\includegraphics[scale=1]{border}}}

\begin{document}
\lipsum[1-20]
\end{document}

An image of the first page of the resulting document:

enter image description here

Here's the code I used toproduce the border used:

\documentclass{article}
\usepackage[dvipsnames]{xcolor} 
\usepackage[object=vectorian]{pgfornament}
\usetikzlibrary{calc}

\definecolor{mycolor}{cmyk}{0,0,0.1,0}

\pagestyle{empty}
\begin{document}
\color{mycolor}
\begin{tikzpicture}[remember picture,overlay] 
\coordinate (a) at ( $ (current page.north west) +  (1cm,-1cm)$); 
\coordinate (b) at ( $ (current page.south west) +  (1cm,1cm)$); 
\coordinate (c) at ( $ (current page.south east) +  (-1cm,1cm)$); 
\coordinate (d) at ( $ (current page.north east) +  (-1cm,-1cm)$); 
\fill[Maroon] (current page.south west) rectangle ( $ (current page.north west) + (2cm,0) $);
\fill[Maroon] (current page.south east) rectangle ( $ (current page.north east) + (-2cm,0) $);
\fill[Maroon] (current page.north west) rectangle ( $ (current page.north east) + (0,-2cm) $);
\fill[Maroon] (current page.south west) rectangle ( $ (current page.south east) + (0,2cm) $);
\pgfornamenthline{a}{d}{north}{87}
\pgfornamenthline{b}{c}{south}{87}
\pgfornamentvline{a}{b}{west}{87}
\pgfornamentvline{c}{d}{east}{87} 
\end{tikzpicture}
\end{document}
8
  • Do you know why this fails if babel is loaded with french?
    – cfr
    Commented Apr 13, 2014 at 20:32
  • @cfr is the problem of some babel modules making active some characters that TikZ uses. The quickest solution is to use the babel library: \usetikzlibrary{babel} (for version 3.0.0 of TikZ); other wise, you will need to use every picture/.append style to invoke \shorthandoff for the problematic charcater(s). Commented Apr 13, 2014 at 20:38
  • Thanks! Normally I only use 2 languages with babel and one is English while the other is, let's say, minimal in its support of anything. (Hyphenation patterns and a very few translations many of which are non-optimal is about it.) But I was trying to answer a question which used French and so surprised that turned out to be the problem. I guess there are advantages to using a radically under-supported language which does next-to-nothing after all!
    – cfr
    Commented Apr 13, 2014 at 20:56
  • @cfr yes; the spanish module, for example, tries to implement a lot of the Spanish rules dictated by our Real Academia and in doing so generates many incompatibilities with some packages (with TikZ, for example, but also with lipsum!); a non-experienced user can become really clueless as to where the problem might be. Commented Apr 13, 2014 at 21:06
  • I, on the other hand, have yet to come across a problem created by welsh other than mistranslations ;). Then again, the fact that the language is not supported by the T1 encoding, that translations are non-existent in most cases and that nothing else has ever heard of it is not unproblematic... [Or any other encoding. The only one which supports it is berenisadf in LY1.]
    – cfr
    Commented Apr 13, 2014 at 21:30

You must log in to answer this question.

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