A LaTeX kernel change from Dec 2018 caused different behavior in \smash
, which affected this answer. Thanks to Ulrike for diagnosing the issue for me and providing the best fix at Change in everypage package behavior (which hasn't been revised since 2007)
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}
% ORIGINAL DEFINITION
\newcommand\atxy[3]{%
\AddThispageHook{\hbox{\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}
\put
will also work BTW.