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.

Using LaTeX, I'm trying to fit into the header a minipage containing the page number above a logo. However,

  1. The minipage is pushed out of the header into the head separation space;
  2. The distance between the page number and the logo varies from page to page.

How do I get it right without using fancyhdr?

Here is the code:

\NeedsTeXFormat{LaTeX2e}[2001/06/01]
\ProvidesClass{blabla}[2012/01/22 v2.0.2 blabla class]
\RequirePackage{geometry}
\RequirePackage{graphicx}
\RequirePackage{float}
\LoadClass[12pt, legalpaper, oneside, final]{article}
\geometry{top=6mm, headheight=40mm, headsep=40mm, total={165mm,243mm}, includeheadfoot}
\AtEndOfClass{\pagestyle{blabla}}

\def\ps@blabla{
\def\@oddhead{
\begin{minipage}{\textwidth}
\vspace{8mm}
\begin{center}
Page \arabic{page}
\end{center}
\vspace{-6mm}
\begin{figure}[H]
\centering
\includegraphics[width=17mm]{logo.png}
\end{figure}
\end{minipage}}

\def\@oddfoot{
\begin{minipage}{\textwidth}
blabla
\end{minipage}}

\def\@evenhead{\@oddhead} \def\@evenfoot{\@oddfoot}}

\endinput
share|improve this question
    
Why is fancyhdr not an option? –  Werner May 30 '12 at 18:26
add comment

1 Answer

I don't see why using a complicated way, when fancyhdr can do it more easily:

\documentclass{article}
\usepackage{fancyhdr}

\usepackage{geometry}
\usepackage[demo]{graphicx}
\geometry{top=6mm, headheight=40mm, headsep=40mm, total={165mm,243mm}, includeheadfoot}

\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}
\fancyhead[L]{%
  \begin{minipage}{\textwidth}
  \vspace{8mm}
  \centering
  Page \arabic{page}\\[6pt]
  \includegraphics[width=17mm,height=17mm]{logo.png}
\end{minipage}}

\fancyfoot[L]{\begin{minipage}{\textwidth}
blabla
\end{minipage}}

\usepackage{kantlipsum}

\begin{document}
\kant
\end{document}

The demo option to graphicx is just for avoiding to have the picture. Note that a figure environment is not necessary for using \includegraphics.

You can fix the height reserved for the header by not setting headheight and letting fancyhdr suggest the suitable value; for example, with this code fancyhdr tells that the height is 86.90962pt, so setting headheight=90pt will be sufficient.

share|improve this answer
    
Thank you for the valuable advice concerning the redundancy of a figure environment for using \includegraphics. It seems to me that in fancyhdr one can manage without minipages. –  Christopher Jun 2 '12 at 15:23
    
@Christopher It should be pointed out that figure environments are not actually redundant to \includegraphics. @egreg's hint refers to your specific purpose being not a common use case for a float, which is what a figure defines. –  dgs Jun 2 '12 at 16:54
add comment

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.