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.

I know that there is tikz, but also eso-pic and textpos. I'd like to see a list of possible ways (not necessarily packages) for absolute positioning of things (which I believe amounts to "boxes") on the page, together with their advantages and disadvantages (for instance: tikz's current page node is very easy to use, but usually requires two LaTeX runs, and overhead from loading tikz if you don't need it for any other things is considerable).

Both LaTeX and ConTeXt solutions are welcome

share|improve this question
    
Good idea to have a reference with one method per answer. Can you please add whether this can disturb the positioning of other material on the page (unlike overlay option). Simple \put will also work BTW. –  Harish Kumar Apr 5 at 22:40
    
\raisebox{\up}[0pt][0pt]{\rlap{\hspace{\right}{anything}}} will position anything relative to the starting position, so if you start at a known absolute position (such as the upper left corner of the text area) Bob is now your uncle. –  John Kormylo Apr 6 at 0:04
1  
The ConTeXt way for absolute (or relative!) is using Layers. –  Aditya Apr 7 at 16:02
    
@Aditya: I know, I even used them once or twice;). But for this big-list question to be useful for newbies, could you provide an example? –  mbork Apr 7 at 16:11
    
@mbork: I'll try to add a detailed answer. If only a day had more than 24 hours. –  Aditya Apr 7 at 16:13

3 Answers 3

Here is the tikz method which uses current page.south west anchor to position the text:

enter image description here

The \AbsolutePosition places the given text at the offset specified relative to the bottom left margin (whose coordinates are determined via the output of the \layout on the first page of the output.

Notes:

  • The showframe package was used just to show the page margins. It is not needed in actual use.
  • The layout package was used to determine the various offsets to apply to make to coordinates relative to the bottom left margin as opposed to the actual bottom left of the page.
  • The lipsum package was used just to provide dummy text.

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum,showframe,layout}

%% Following obtained from \layout. May need adjustment based on class and
%% page settings.  Alternatively, can set these to 0pt and then position will
%% be relative to bottom left of page.
\newcommand*{\BottomLeftX}{1.0in+\hoffset+\oddsidemargin}%
\newcommand*{\BottomLeftY}{\paperheight-1.0in-\voffset-\topmargin-\headheight-\headsep-\textheight}%

\newcommand*{\AbsolutePosition}[4][]{%
    % #1 = tikz options
    % #2 = x (from south west corner of page
    % #3 = y
    % #4 = text
    \begin{tikzpicture}[remember picture,overlay, ultra thick]
        %\draw [shift={(#2,#3)},#1]  (current page.south west) circle (2pt) 
        \draw [#1]  ($(current page.south west) + (\BottomLeftX,\BottomLeftY) + (#2,#3)$) circle (2pt) 
                node[above right] {#4};
    \end{tikzpicture}%
}


\begin{document}\layout
\lipsum[1-3]
\AbsolutePosition[fill=red,draw=red]{5.0cm}{6.0cm}{$(5,6)$}
\AbsolutePosition[fill=green,draw=green]{2.0cm}{2.0cm}{$(2,2)$}
\AbsolutePosition[fill=blue,draw=blue]{1.0cm}{0.0cm}{$(1,0)$}
\end{document}
share|improve this answer

This method allows you to position at any (x,y) location (relative to upper left corner of paper) on the page, and can be issued regardless of where the current location is. The only requirement is that you know what the top and left margins are, which are incorporated in \atxy. It uses the everypage package.

If you prefer the origin at a different location, for example, relative to the margins, that is a trivial change.

\documentclass{article}
\usepackage{everypage}
\usepackage{xcolor}
\usepackage{lipsum}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
 \AddThispageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
  \raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{\textcolor{red}{#3}}}}}
% VERIFIED THAT SETTING \hoffset AND \voffset DO NOT BREAK SOLUTION.
%\hoffset=0.4in
%\voffset=0.2in
\begin{document}
\atxy{6in}{4in}{(6,4)}
\lipsum[1]
\atxy{0in}{1in}{(0,1)}
\atxy{5in}{6in}{\textbullet(5,6)}
\atxy{5in}{6.2in}{\makebox[0pt]{centered at (5,6.2)}}
\end{document}

enter image description here

share|improve this answer

eso-pic provides hooks into specific page locations:

enter image description here

\documentclass{article}
\usepackage{geometry,lipsum,xcolor}
\geometry{showframe,margin=1in}% Just for this example
\usepackage{eso-pic}
\begin{document}
\AddToShipoutPictureBG*{%
  \AtPageUpperLeft{\raisebox{-\height}{\color{red}Page upper left}}%
  \AtPageLowerLeft{\color{blue}Page lower left}%
}%
\AddToShipoutPictureFG*{%
  \AtPageCenter{\makebox[0pt]{\color{green}\Huge DRAFT}}%
  \AtTextUpperLeft{\raisebox{-\height}{\color{brown}Text upper left}}%
  \AtTextLowerLeft{\color{purple}Text lower left}%
  \AtTextLowerLeft{\hspace*{-.5in}\raisebox{3\baselineskip}{$\bullet$}}
}%
\lipsum
\end{document}

Advantage(s):

  • Single compile;
  • Foreground and/or background placement;
  • Per-page or multiple pages

Disadvantage(s):

  • Absolute positioning requires one of the hooks as a starting point (very minor drawback)

Using the location-hooks as a starting point, one can position content across the page.

The starred [unstarred] versions add content to the current page only [every page from then onward].

share|improve this answer

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.