# Overlapping text using eso-pic with scrlttr2

I'm using eso-pic to annotate this letter, using scrlttr2, courtesy of an earlier answer by daleif to the question "Writing TeX file name at the top of the processed document for article class". As you can see, there is a little problem with overlapping text. What is the simplest way to fix this?

The annotation is generated by Mercurial and represents the last commit timestamp (see Embedding Mercurial version control information in a TeX document), but I'm hard-wiring it in, because this question doesn't have anything to do with Mercurial.

\documentclass[foldmarks=true,foldmarks=blmtP,fromalign=false,version=last]{scrlttr2}
\usepackage{fouriernc}
% Add code to annotate file with file name and hash of last hg cset to change the file.
\usepackage{eso-pic,picture}
% change reference point to page upper left
\AtPageUpperLeft{
\put(\oddsidemargin+1in+0.5\textwidth,-1cm){%
\makebox[0pt][c]{\textbf{shaw.tex} 09da3da30168bc8301b68b894b0414cd87ba0a16 2014-08-30 18:13 +0530 } }
}
}
\usepackage[T1]{fontenc}
\begin{document}
\setkomavar{fromname}{H. G. Wells}

\def\today{1st January, 1895}
\begin{letter}{
George Bernard Shaw,\\
Shaw's Corner,\\
Bibbs Hall Lane,\\
Ayot St. Lawrence, Hertfordshire\\}

\opening{Dear Shaw,}

You suck!

\closing{Sincerely}
\end{letter}
\end{document}


UPDATE:

Thanks to Steven for his helpful response.

I remember the last time I asked about annotating a LaTeX file, per What are the ways to position things absolutely on the page? for example, someone made the distinction about writing on top of the TeX without regard to what was already there (which means it might overwrite stuff), or putting it in a "provided" slot, say at the top of the page. I don't remember the details. Does anyone have a link to something about this?

I employed my answer at What are the ways to position things absolutely on the page? to your problem. It uses everypage rather than eso-pic (see below for eso-pic version). Note that, as written, \atxy only places the overtext on the page from which it is invoked. However, if you wanted the overtext on every page, you could change the \AddThispageHook to \AddEverypageHook.

\documentclass[foldmarks=true,foldmarks=blmtP,fromalign=false,version=last]{scrlttr2}
\usepackage{fouriernc}
% Add code to annotate file with file name and hash of last hg cset to change the file.
%\usepackage{eso-pic,picture}
\usepackage[T1]{fontenc}
%
\usepackage{everypage}
\usepackage{lipsum}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
\raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
\atxy{.5\paperwidth}{0.5cm}{\makebox[0pt]{%
\textbf{shaw.tex} 09da3da30168bc8301b68b894b0414cd87ba0a16 2014-08-30 18:13 +0530}}
\begin{document}
\setkomavar{fromname}{H. G. Wells}

\def\today{1st January, 1895}
\begin{letter}{
George Bernard Shaw,\\
Shaw's Corner,\\
Bibbs Hall Lane,\\
Ayot St. Lawrence, Hertfordshire\\}

\opening{Dear Shaw,}

You suck!

\closing{Sincerely}
\end{letter}
\end{document}


A comparable solution can be obtained with eso-pic by changing, in the OP's original MWE, the -1cm to -0.5cm, inside the \put, as in

\documentclass[foldmarks=true,foldmarks=blmtP,fromalign=false,version=last]{scrlttr2}
\usepackage{fouriernc}
% Add code to annotate file with file name and hash of last hg cset to change the file.
\usepackage{eso-pic,picture}
% change reference point to page upper left
\AtPageUpperLeft{
\put(\oddsidemargin+1in+0.5\textwidth,-0.5cm){%
\makebox[0pt][c]{\textbf{shaw.tex} 09da3da30168bc8301b68b894b0414cd87ba0a16 2014-08-30 18:13 +0530 } }
}
}
\usepackage[T1]{fontenc}
\begin{document}
\setkomavar{fromname}{H. G. Wells}

\def\today{1st January, 1895}
\begin{letter}{
George Bernard Shaw,\\
Shaw's Corner,\\
Bibbs Hall Lane,\\
Ayot St. Lawrence, Hertfordshire\\}

\opening{Dear Shaw,}

You suck!

\closing{Sincerely}
\end{letter}
\end{document}

• Hi Steven, thanks for the reply. Is there any way to do this using eso-pic? Also, can you explain why eso-pic is not working? Finally, could you explain briefly how your method works? This would be helpful in case I need to adjust it in future. – Faheem Mitha Sep 1 '14 at 16:03
• @FaheemMitha When outputting with everypage routines, the "current" position is \hoffset+\PageLeftMargin from the left side of the paper, and \voffset+\PageTopMargin from the top of the paper. Thus, to position absolutely on the page, I subtract these dimensions from the x and y positions (taking me to the upper left paper corner), respectively, and then add in the user specified offset distances. The \smash is so that it does not affect subsequent page text. The y-position is handled with a \raisebox and x-position with a \hspace*. I don't know eso-pic to help there. – Steven B. Segletes Sep 1 '14 at 19:18
• @FaheemMitha See updated answer for eso-pic answer. – Steven B. Segletes Sep 1 '14 at 19:21