GeneralCustom headers impossible ?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
xApple
Posts: 3
Joined: Sun Nov 09, 2008 5:09 pm

Custom headers impossible ?

Post by xApple »

Hello,
I just started using Latex, thinking it could be a nice thing to do for my next report hand-in forgetting my classical WYSIWYG software. However, a few minutes into the task and I am already stuck on strange problem. Before even typing the content of report I tried to mimic the cool header I usually use in all my reports - a small box with my name, the name of the professor, the date and the page number.

This simple problem of having a custom header appear on the top of every page proved to be near impossible to solve. I searched the web, googled extensively, ended up reading all the documentation of the "fancyheaders" package only to conclude this would be of no use for my problem.

Fancyheaders gives a bit more freedom on the types of headers used but not at all enough to reproduce my usual header that I have attached as illustration.

Help greatly appreciated.
Attachments
NiceHeader.pdf
An illustration of the usual header box I use.
(150.56 KiB) Downloaded 331 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Custom headers impossible ?

Post by phi »

Hello,

the following could be a good starting point:

Code: Select all

\documentclass{article}

\usepackage{lipsum}

\usepackage{fancyhdr}
\usepackage{lastpage}

\pagestyle{fancy}

\setlength\headheight{4\baselineskip}
\fancyheadoffset{6em}
\let\headrule\relax

\chead{
  \begin{tabular}{|p{7cm}|p{5cm}@{}p{2cm}|}
    \hline
    \textbf{Student:} Bob Smith \newline
    \textbf{Professor:} Pierre Muller \newline
    Life Sciences Faculty &
    \textbf{Homework hand-in} \newline
    7 november 2008 \newline
    Page \thepage\ of \pageref{LastPage} &
    LOGO \\
    \hline
  \end{tabular}
}


\begin{document}

\lipsum[1-10]

\end{document}
xApple
Posts: 3
Joined: Sun Nov 09, 2008 5:09 pm

Custom headers impossible ?

Post by xApple »

Wow, thanks alot, that indeed does do the trick pretty well !
Although I do have a little problem when adding the logo. When replacing the line "LOGO //" with the includegraphics commands as is shown here:

Code: Select all

\chead{
  \begin{tabular}{|p{7cm}|p{5cm}@{}p{3.5cm}|}
    \hline
    \textbf{Student:} Bob Smith \newline
    \textbf{Professor:} Pierre Muller \newline
    Life Sciences Faculty &
    \textbf{Homework hand-in} \newline
    7 november 2008 \newline
    Page \thepage\ of \pageref{LastPage} &
    \includegraphics[height=15mm]{epfl.png}  \\
    \hline
  \end{tabular}
}
This causes the box to grow and the logo to be placed on the top while the text is pushed down : (
(See attachement)

Any ideas ? Thanks.
Attachments
Before after replacing the "LOGO" line
Before after replacing the "LOGO" line
AddingLogo.png (124.56 KiB) Viewed 4193 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10360
Joined: Mon Mar 10, 2008 9:44 pm

Custom headers impossible ?

Post by Stefan Kottwitz »

There's a trick that will help: just insert \vspace{0pt} right before \includegraphics. For an explanation and a similar example have a look at Vertical alignment of graphics.

Stefan
LaTeX.org admin
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Custom headers impossible ?

Post by Juanjo »

An alternative could be to replace \includegraphics by \raisebox{-10mm}{\includegraphics[height=12mm]{lepfl.png}}, where instead of -10mm, you should choose an appropriate length.

In the log file, up to now, you surely have a warning like this:

Code: Select all

Package Fancyhdr Warning: \headheight is too small (48.0pt): 
 Make it at least 71.94328pt.
If one arranged the logo, you still see a warning, replace \setlength\headheight{4\baselineskip} by \setlength\headheight{XXX}, where XXX is the length suggested by the warning (72pt in the above example).
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
xApple
Posts: 3
Joined: Sun Nov 09, 2008 5:09 pm

Re: Custom headers impossible ?

Post by xApple »

Thanks a lot guys ! Your last advice worked like a charm (added a little \hspace and it's perfect)
You made be feel like pursuing LaTeX and making more reports using it !

Cheers !
Post Reply