7

For a wiki site dedicated to collaborative editing of lecture notes in full LaTeX documents, I’d like to add a box with meta-information onto the first page of the resulting PDF file – this is inspired by what arXiv.org does.

I’d prefer to create the box using LaTeX, but avoid having to mechanically inject it into the existing LaTeX code.

What would be the most robust and clean way of doing so?

2 Answers2

5

One option is to use the background package; using its some option, no material is placed in the pages; the material will only be displayed in those pages in which you invoke \BgThispage (somewhere in the first page, in your case). The material attributes (color, position, opacity, etc.) can be highly customized; a little example:

\documentclass{article}
\usepackage[some]{background}
\usepackage{lipsum}

\SetBgContents{Some Additional Information -- \today}
\SetBgColor{gray}
\SetBgOpacity{1}
\SetBgScale{2}
\SetBgAngle{90}
\SetBgPosition{current page.west}
\SetBgVshift{-1.8cm}
\SetBgHshift{-1cm}

\title{The Title}
\author{The Author}

\begin{document}

\maketitle
\BgThispage
\begin{abstract}
\lipsum[4]
\end{abstract}
\lipsum[1-13]

\end{document}

An image of the first two pages:

enter image description here

Gonzalo Medina
  • 505,128
  • Certainly looks good, but this requires changes to the TeX source; I’d like to avoid that as I fear that it might not work reliable. – Joachim Breitner Aug 05 '12 at 21:17
1

Exactly the same as Gonzalo's answer, but you don't modify the original tex file, you just \input it into one that adds the background. (I don't know if this would be a feasible solution for you, if you're only concerned with not having to manually edit the original document?)

So, q65980-maindoc.tex knows nothing about the background:

\documentclass{article}
\usepackage{lipsum}

\title{The Title}
\author{The Author}

\begin{document}

\maketitle

\begin{abstract}
\lipsum[4]
\end{abstract}
\lipsum[1-13]

\end{document}

And you have a new file called q65980-with-background.tex say with the following:

\RequirePackage[some]{background}

\SetBgContents{Some Additional Information -- \today}
\SetBgColor{gray}
\SetBgOpacity{1}
\SetBgScale{2}
\SetBgAngle{90}
\SetBgPosition{current page.west}
\SetBgVshift{-1.8cm}
\SetBgHshift{-1cm}

\AtBeginDocument{\BgThispage}

\input{q65980-maindoc}

This seems to work, at least on Gonzalo's example, but I can't promise how robust it will be. Try it on your real examples and see?

The only way of preserving annotations and things in the pdf like hyperlinks will be to reprocess the source of the original document in some way similar to this (rather than just including the compiled PDF), because PDF annotations cannot readily be copied from one PDF into another.