13

I'm using Linux on a server (CentOS 5) to generate a one page PDF report using LaTeX. The LaTeX distribution is quite old - latex --version returns the following:

pdfeTeX 3.141592-1.21a-2.2 (Web2C 7.5.4)
kpathsea version 3.5.4
Copyright (C) 1997-2004 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Kpathsea is copyright (C) 1997-2004 Free Software Foundation, Inc.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfeTeX copyright and
the GNU General Public License.
For more information about these matters, see the files
named COPYING and the pdfeTeX source.
Primary author of pdfeTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Kpathsea written by Karl Berry and others.

As a result, there are several packages that are not available to me (wallpaper for example). I've made a pdf file for headers and footers which I insert as figures at the top and bottom of the page, and have some images inserted in the center part of the page. Is there a way that I can specify the location of objects using co-ordinates, rather than letting LaTeX choose the positioning? For the most part my current layout is satisfactory, but I would like to make sure that my footer is locked to the bottom of the page (for example).

I'd prefer not to install a recent version of LaTeX on the server as most things are currently working but just need some fine tuning.

21

Place a \begin{picture}(0,0) in the header of the page so that it makes a zero-sized box at a know position, then you can \put text or graphics at exact coordinates relative to that box.

There is an example of this technique in my answer to

Implementing line-based corporate design in LaTeX

12

Just to expand on the other two answer with a small example:

\documentclass{article}
\usepackage[left=1in,right=1in]{geometry}
\usepackage{xcolor,rotating,picture,lipsum}
\makeatletter

\def\even@samplepage{%
 \begin{picture}(0,0)
   \put(\Xeven,\Yeven){\turnbox{90}{\Huge \textcolor{\watermark@textcolor}{\watermark@text}}}
\end{picture}
}
%% Define a macro to print SAMPLE PAGE IN THE MARGIN
\def\odd@samplepage{%
 \begin{picture}(0,0)
   \put(\Xodd,\Yodd){\turnbox{90}{\Huge \textcolor{\watermark@textcolor}{\watermark@text}}}
 \end{picture}
}

\def\watermarktext#1{\gdef\watermark@text{\fontfamily{phv}\selectfont#1}}
\def\watermarktextcolor#1{\gdef\watermark@textcolor{#1}}
\watermarktext{PRE-PRINT}
\watermarktextcolor{purple}
% fix headings
\def\ps@samplepage{\let\@mkboth\@gobbletwo
 \let\@oddhead\odd@samplepage\def\@oddfoot{\reset@font\hfil\thepage}
 \let\@evenhead\even@samplepage\def\@evenfoot{\reset@font\thepage\hfil}}
%%
\def\Xodd{500}
\def\Xeven{-70}\def\Yeven{-810}
\def\Yeven{-\expandafter\strip@pt\textheight}
\let\Yodd\Yeven
\makeatother
\begin{document}
\thispagestyle{samplepage}
\lipsum
\end{document}

enter image description here

The important part, as the other posters mentioned is to use the picture environment.

 \def\even@samplepage{%
 \begin{picture}(0,0)
 \put(\Xeven,\Yeven){\turnbox{90}{\Huge \textcolor{\watermark@textcolor}   {\watermark@text}}}
 \end{picture}
 }

Using the textpos package:

 \documentclass{article}
 \usepackage[absolute]{textpos}
 \setlength{\TPHorizModule}{1mm}%
 \setlength{\TPVertModule}{1mm}%
 \begin{document}
 \begin{textblock}{200}(50,30)%
   This is a test
 \end{textblock}%
 \end{document}
  • For a simple example, if I do the following: \begin{picture}(0,0) \put(6,3){}{text} \end{picture} this does not quite work for repositioning, but it does appear on the page. How can I adjust the location? I found it a little hard to understand what all the arguments are in the above example. – celenius Mar 28 '12 at 15:24
  • @celenius You want the text to repeat on every page or on a specific page only? – Yiannis Lazarides Mar 28 '12 at 15:28
  • It's just a one page document so there is no repetition. – celenius Mar 28 '12 at 15:30
  • 2
    @celenius Then you better off with texpos, I will post a short example. – Yiannis Lazarides Mar 28 '12 at 15:35
  • Are there any special considerations if I put a figure into the textblock? It works on TexWorks for me, but not with latex on my server. I get a variety of error messages, the first being You can't use \prevdepth' in restricted horizontal mode.` – celenius Mar 28 '12 at 16:26
6

The textpos package might be what you're looking for.

  • 2
    +1, but could you add a little document demonstrating a really basic usage case of textpos? – doncherry Mar 28 '12 at 14:39
  • I'm not myself a textpos user, but the documentation in the directory I linked to contains a short example and there's a larger example niepraschk-eso-pic.tex which shows the combination with eso-pic. HTH. – Stephan Lehmke Mar 28 '12 at 14:51
1

At http://www.texample.net/tikz/examples/exam-sheet/ there is a very nice tikz solution with working code. It allows the instructor to dogear the corner hiding the name until the grading is completed. It works well for one-page quizzes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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