# Understanding (la)tex calculations: distance from top of page

I am deriving a class from article. My first task was adjusting margins and widths. My second task is putting a header on top of the title page. Instead of placing each component individually, I created one graphic I want to place at the top left corner of the title page. While horizontal placement/calculations work as expected, moving towards the top of the page is cumbersome.

My class file so far

\LoadClassWithOptions{llncs}

\setlength{\textwidth}{170mm}
\setlength{\textheight}{270.6mm}

\setlength\oddsidemargin   {20mm}
\setlength\evensidemargin  {20mm}
\setlength\marginparwidth  {0\p@}

\setlength\hoffset {-1in}

\setlength\voffset {8mm}
\setlength\topmargin {-1in}

\setlength\footskip   {3.8mm}

\RequirePackage{graphicx}


As the header is suppoed to appear only on the title page, I figure putting it with the title makes sense. To place the title, there is a macro \@maketitle. I copied its definition to my new class file to make my modifications. Originally, the title is placed within a center environment. I put my header just before that environment, like this:

\hskip -\oddsidemargin%
\hskip -6.1925mm%


Using \hskip has exactly the effect I want: the header appears at the left edge of the page. This addition makes my header appear 8mm from the top of the page, which is the value of \voffset. Notice, I used the \voffset and \topmargin combination as I did because the document wouldn't compile with a negative value for \voffset.

To move the header up to the top edge of the page I prepend the \hskip statement with

\vspace*{-\voffset}%


... which does not yield the expected result. This line moves the header up by 3mm. To displace it the full 8mm, i.e. make the header appear in the top left corner of the page, I had to

\vspace*{-12.575mm}%


which is everything but intuitive to me. I got that value through trial and error.

Why does LaTeX behave like that?

Here is my complete class files with the adapted \@maketitle:

(I put a \rule instead of includegraphics)

baseclass.cls:

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{baseclass}[2010/07/12 v2.17
^^J LaTeX document class for Lecture Notes in Computer Science]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\RequirePackage{multicol} % needed for the list of participants, index
\RequirePackage{aliascnt}
\RequirePackage{graphicx}
\RequirePackage{lastpage}
\newcommand{\bibtexstyle}{splncs03} % Springer Style
\endinput


techclass.cls

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{techclass}[2015/02/08 v0.1
^^J LaTeX document class for technical papers]
\setlength{\textwidth}{170mm}
\setlength{\textheight}{270.6mm}
\renewcommand\@pnumwidth{2em}
\renewcommand\@tocrmarg{3.5em}
\setlength\oddsidemargin   {20mm}
\setlength\evensidemargin  {20mm}
\setlength\marginparwidth  {0\p@}
\setlength\voffset {-1in}
\setlength\topmargin {8mm}
\setlength\footskip   {3.8mm}
\setlength\footnotesep{7.7\p@}
\setlength\textfloatsep{8mm\@plus 2\p@ \@minus 4\p@}
\setlength\intextsep   {8mm\@plus 2\p@ \@minus 2\p@}
\setlength\hoffset {-1in}
\def\@maketitle{\newpage
\markboth{}{}%
\def\lastand{\ifnum\value{@inst}=2\relax
\unskip{} \andname\
\else
\unskip \lastandname\
\fi}%
\def\and{\stepcounter{@auth}\relax
\ifnum\value{@auth}=\value{@inst}%
\lastand
\else
\unskip,
\fi}%
\vspace*{-12.575mm}%
\hskip -\oddsidemargin%
\hskip -6.1925mm
\rule{\textwidth}{3cm}
\begin{center}%
\let\newline\\
{\Large \bfseries\boldmath
\pretolerance=10000
\@title \par}\vskip .8cm
{\lineskip .5em
\noindent\ignorespaces
\@author\vskip.35cm}
%{\small\institutename}
\end{center}%
}
\pagestyle{plain}
\let\pagestyle\relax
\def\strpage{Page}
\def\strof{of}
\def\@oddfoot{\hfil\strpage~\thepage~\strof~\pageref{LastPage}}
\let\@evenfoot\@oddfoot
\endinput


And here's a fairly MWE:

\documentclass[12pt,a4paper]{techclass}

\begin{document}%
\title{Hello World}
\author{%
Foo B. Baz
}
\maketitle
\begin{abstract}
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
\end{abstract}

one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three

one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three

\end{document}


my working document:

\documentclass[12pt,a4paper]{techclass}
\newcommand{\mytitle}{How to use this template}
\newcommand{\pdfmetainfo}{My Name Removed}
\usepackage{ifpdf}
\usepackage[english]{babel}
\usepackage{paralist}
\usepackage{tabularx}
\usepackage{layout}
\usepackage{ifluatex}
\ifluatex
\usepackage[latin1]{luainputenc}
\else
\usepackage[latin1]{inputenc}
\fi
\ifpdf
\pdfcompresslevel=9
\usepackage{hyperref}
\hypersetup{ a4paper=true,
plainpages=false,
pdftex=true,
hyperindex=true,
bookmarks=true,
bookmarksopen=true,
bookmarksnumbered=true,
pdfauthor={\pdfmetainfo},
pdftitle={\mytitle}
}
\fi
\newcommand{\bibtexinputfiles}{paper}
\newcommand{\docbegin}[0]{%
\begin{document}%
}
\newcommand{\mybibliography}[0]{%
\ifpdf%
\pdfbookmark[0]{Bibliography}{bibphy}%
\fi%
\bibliographystyle{\bibtexstyle}%
\bibliography{\bibtexinputfiles}%
}
\newcommand{\docend}[0]{%

\end{document}
}

\docbegin
\title{\mytitle}
\author{%
My Name Removed
}
\maketitle
\begin{abstract}
one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three
\end{abstract}
\nocite{*}
\mybibliography
\docend

• why start from llncs? a strange starting point. – David Carlisle Feb 8 '15 at 13:26
• setting \headheight to 0 looks very strange, do you never have running heads? – David Carlisle Feb 8 '15 at 13:34
• if I use \setlength\voffset {-1in} \setlength\topmargin {0mm} and just comment out your \vspace*{-12.7mm}% then it seems to work for me and look a bit more understandable? – David Carlisle Feb 8 '15 at 13:41
• @DavidCarlisle: I started from llncs because that's what we have been using up until now. No, we never have running heads, everything has to go in the footer. When I put a negative value for \voffset I get a ! LaTeX Error: Bad \line or \vector argument. – Bananguin Feb 8 '15 at 13:56
• Yo do not get an error from the document as posted if you make that change. If there is an error elsewhere I can't comment:-) – David Carlisle Feb 8 '15 at 14:36

This places the rule in the top corner.

I added \noindent so that it wasn't shifted to the right, removed the "by eye" vertical adjustments and added a negative space of exactly \vspace*{-\dimexpr\topskip+\topmargin+\lineskip\relax}% before the rule.

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{techclass}[2015/02/08 v0.1
^^J LaTeX document class for technical papers]
\setlength{\textwidth}{170mm}
\setlength{\textheight}{270.6mm}
\renewcommand\@pnumwidth{2em}
\renewcommand\@tocrmarg{3.5em}
\setlength\oddsidemargin   {20mm}
\setlength\evensidemargin  {20mm}
\setlength\marginparwidth  {0\p@}
\setlength\voffset {-1in}
%\setlength\topmargin {8mm}
\setlength\footskip   {3.8mm}
\setlength\footnotesep{7.7\p@}
\setlength\textfloatsep{8mm\@plus 2\p@ \@minus 4\p@}
\setlength\intextsep   {8mm\@plus 2\p@ \@minus 2\p@}
\setlength\hoffset {-1in}
\def\@maketitle{\newpage
\markboth{}{}%
\def\lastand{\ifnum\value{@inst}=2\relax
\unskip{} \andname\
\else
\unskip \lastandname\
\fi}%
\def\and{\stepcounter{@auth}\relax
\ifnum\value{@auth}=\value{@inst}%
\lastand
\else
\unskip,
\fi}%
\vspace*{-\dimexpr\topskip+\topmargin+\lineskip\relax}%
\noindent\hskip -\oddsidemargin%
% \hskip -6.1925mm
\rule{\textwidth}{3cm}
\begin{center}%
\let\newline\\
{\Large \bfseries\boldmath
\pretolerance=10000
\@title \par}\vskip .8cm
{\lineskip .5em
\noindent\ignorespaces
\@author\vskip.35cm}
%{\small\institutename}
\end{center}%
}
\pagestyle{plain}
\let\pagestyle\relax
\def\strpage{Page}
\def\strof{of}
\def\@oddfoot{\hfil\strpage~\thepage~\strof~\pageref{LastPage}}
\let\@evenfoot\@oddfoot
\endinput

• Thanks for the all inclusive service! I suppose top- and lineskip are glue and that's why 8mm have the effect of 3mm ... – Bananguin Feb 9 '15 at 8:11

replace

\setlength\voffset {8mm}
\setlength\topmargin {-1in}


by

\setlength\voffset {8mm}
\setlength\topmargin {-1in}

\setlength\topmargin {-1in}