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.

I've been struggling with my .tex for quite some time now, and decided its time to look for help.

This is the situation: all docs here (my office) need to bring, as header, a table (3 columns) which contains logo & title & page count.

Also, as footer, it must have a table (2 columns) which contains text & text.

I'm using the book documentstyle because I need the summary and chapter structure.

I've already tried the \background package, but it seens to not accept tables as content.

So, here is the question: could you point me the direction I must follow?

I wanted to include a picture, but my rep doesn't allow me....


Update: 05-09-2013

Trying new code now, thanks for your help!

the code:

    \documentclass[a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage{hyperref}
\usepackage{array}
\usepackage{lastpage}
\usepackage{lipsum}

\usepackage{fancyhdr}
\usepackage[hmargin=2cm,top=4cm,headheight=65pt,footskip=65pt]{geometry}

\setlength{\parindent}{0.95cm}

\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[C]{%
          \begin{tabular}{|m{3.0cm}|m{10.0cm}|m{2.5cm}|}
          \hline
          \includegraphics[height=1.5cm,width=2.5cm]{logo.png} &
          \centering
          \Huge{TITLE} &
          \centering
          \tiny{P\'ag. \thepage\ de \pageref{LastPage}\\
          Data: 17/05/2013\\
          Rev. 0}\tabularnewline
          \hline
          \end{tabular}%
}
\fancyfoot[C]{%
          \begin{tabular}{|m{3.0cm}|m{10.0cm}|m{2.5cm}|}
          \hline
          \includegraphics[height=1.5cm,width=2.5cm]{logo.png} &
          \centering
          \Huge{TITLE} &
          \centering
          \tiny{P\'ag. \thepage\ de \pageref{LastPage}\\
          Data: 17/05/2013\\
          Rev. 0}\tabularnewline
          \hline
          \end{tabular}%
}

\begin{document}
\lipsum[1-10]
\end{document}

produces the table header, but its overlapping the default header. Also, the pages in which a chapter starts, there is no header. I need headers in all pages.

Some pics:

Overlapping Headers Overlapping Headers

Blank header

Blank header

-----------------------------------------------------

Initial code: Could you take a look at my code? its not working the way its supposed to do: its produces only a table, but not as header or footer.

\documentclass[a4paper,12pt]{book}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{epsfig}
\usepackage{float}}
\usepackage{multicol}
\usepackage{array}
\usepackage{multirow}
\usepackage{lastpage}

\usepackage[margin={2cm}]{geometry}

\usepackage[brazilian]{babel}
\usepackage[utf8]{inputenc}



\setlength{\paperheight}{29.7cm} \setlength{\paperwidth}{21cm}

\usepackage{indentfirst}
\setlength{\parindent}{0,95cm}



\usepackage{fancyhdr}
\pagestyle{fancy}

\setlength{\headheight}{16pt}
\fancyhead{
          \begin{table}[t]

          \begin{tabular}{|m{3.0cm}|m{10.0cm}|m{2.0cm}|}

          \hline
          \includegraphics[height=1.5cm]{logo.png} &
          \centering
          \HUGE{TITLE} &
          \centering
          \tiny{Pág. \thepage\ de \pageref{LastPage} 

          Data: 17/05/2013

          Rev. 0}         &
          \hline

          \end{tabular}
          \end{table}
}

%I need a similar table on footer
\fancyfoot[C]{
      \begin{table}[t]

          \begin{tabular}{|m{3.0cm}|m{10.0cm}|m{2.0cm}|}

          \hline
          \includegraphics[height=1.5cm]{logo.png} &
          \centering
          \HUGE{TITLE} &
          \centering
          \tiny{Pág. \thepage\ de \pageref{LastPage} 

          Data: 17/05/2013

          Rev. 0}         &
          \hline

          \end{tabular}
          \end{table}

}


\begin{document}

CONTENTS

\end{document}
share|improve this question
1  
Welcome to TeX-SX! You may have a look at our starter page for a quick intro if you wish to familiarize yourself with our format. –  Claudio Fiandrino May 8 '13 at 15:56
1  
Welcome to TX.SX! If you want, add the image to your question, and remove the leading !. Then a user with editing rights can add the ! back in. –  mafp May 8 '13 at 16:02

1 Answer 1

up vote 3 down vote accepted

Here is a template:

\documentclass{book}

\usepackage{fancyhdr}
\usepackage[demo]{graphicx}   %% take the demo option out for your final document

\pagestyle{fancy}
\setlength{\headheight}{16pt}
\fancyhead[LO,RE]{\includegraphics[width=12pt, height=12pt]{logo}}
\fancyhead[CE]{\rightmark}
\fancyhead[CO]{\leftmark}
\fancyhead[LE,RO]{\thepage}
\fancyfoot[C]{\begin{tabular}{cc}
                text & text
              \end{tabular}%
}

\usepackage{lipsum}
\begin{document}
\chapter{Chapter title}
%% add this if you want the fancy style also on the first page of a chapter:
\thispagestyle{fancy}
\section{Section title}
\lipsum[1-10]
\end{document}

Using the fancyhdr package, you can define headers and footers as you like. For instance, I put the logo in the header, on the left on odd pages (LO), and on the right on even pages (RE). In the center (C) of the footer I put a table as requested. The other settings are similar. Note that normally the first page of a chapter gets the page style plain which usually has only the page number in the footer. If you want the fancy style also on those pages, use \thispagestyle{fancy} directly after \chapter{...}. The template above yields:

sample output

Your code has a few problems:

  • Don't set papersize and paperheight explicitly. The a4paper option for book is enough.
  • The tabulars don't need to be wrapped into tables, as they are not floating objects.
  • There is no \HUGE size, \Huge is the largest.
  • You did not end all table rows with \\.

Fixing those problems leads to the following code:

\documentclass[a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage{hyperref}
\usepackage{array}
\usepackage{lastpage}
\usepackage{lipsum}

\usepackage{fancyhdr}
\usepackage[hmargin=2cm,top=4cm,headheight=65pt,footskip=65pt]{geometry}

\setlength{\parindent}{0.95cm}

\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
\fancyhead[C]{%
          \begin{tabular}{|m{3.0cm}|m{10.0cm}|m{2.5cm}|}
          \hline
          \includegraphics[height=1.5cm,width=2.5cm]{logo.png} &
          \centering
          \Huge{TITLE} &
          \centering
          \tiny{P\'ag. \thepage\ de \pageref{LastPage}\\
          Data: 17/05/2013\\
          Rev. 0}\tabularnewline
          \hline
          \end{tabular}%
}
\fancyfoot[CE,CO,LE,LO,RE,RO]{} %% clear out all footers
\fancyfoot[C]{%
          \begin{tabular}{|m{3.0cm}|m{10.0cm}|m{2.5cm}|}
          \hline
          \includegraphics[height=1.5cm,width=2.5cm]{logo.png} &
          \centering
          \Huge{TITLE} &
          \centering
          \tiny{P\'ag. \thepage\ de \pageref{LastPage}\\
          Data: 17/05/2013\\
          Rev. 0}\tabularnewline
          \hline
          \end{tabular}%
}

\begin{document}
\chapter{Chapter title}
%% add this if you want the fancy style also on the first page of a chapter:
\thispagestyle{fancy}
\section{Section title}
\lipsum[1-10]
\end{document}

and it looks like this:

sample output 2

Note that this uses the same header and footer for odd and even pages. I think you now should be able to adapt the tables to have a right page/left page look, and setting the header with CO and CE positions accordingly.

share|improve this answer
    
Could you take a look at my code? its not working the way its supposed to do: –  erickfis May 8 '13 at 18:19
    
Thank you for being so helpful! –  erickfis May 9 '13 at 16:52
    
But now the table header overlaps the default header, and its not present in all pages. Pages in which a chapter starts get no headers. Let me see if I can post a pic. –  erickfis May 9 '13 at 16:54
    
This did the trick. –  erickfis May 10 '13 at 11:46
    
Thank you very much kindly sir! case closed! –  erickfis May 10 '13 at 11:47

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.