Consider the following MWE.
\documentclass{article}
\usepackage{textpos}
\newcommand{\insertname}{%
\begin{textblock}{2}(5,-0.5)
\bfseries{\jobname.tex}
\end{textblock}
}
\begin{document}
\insertname
Some text.
\end{document}
This places the name of the LaTeX file at the top of the output PDF. However, I'd like this handled automatically, using xpatch, if possible. Then I won't need to manually insert the macro into the body, but will have this handled in the preamble. I've tried using \xpretocmd with \maketitle and \titlepage as arguments in turn, but it does not work. Any suggestions how I can do this?
\documentclass{article}
\usepackage{textpos}
\usepackage{xpatch}
\newcommand{\insertname}{%
\begin{textblock}{2}(5,-0.5)
\bfseries{\jobname.tex}
\end{textblock}
}
\xpretocmd{\maketitle}{\insertname}{}{}
%\xpretocmd{\titlepage}{\insertname}{}{}
\begin{document}
%\insertname
Some text.
\end{document}
The answer by tohecz looks good, but doesn't work with a simple letter example.
\documentclass[11pt]{letter}
\address{Sender address}
\signature{Some person}
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[RO,LE]{\jobname\quad\the\day.~\the\month.~\the\year}
\pagestyle{fancy}
\begin{document}
\begin{letter}{Recipient address}
\opening{Dear Sir/Madam,}
Some stuff
\closing{Thanking you}
\end{letter}
\end{document}
emis a unit of measure, how should that center anything? – daleif Jan 24 '14 at 16:38