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 begin with LaTeX and use fancyhdr. So I've got a sweet footer for all my pages but...I'd like to create one another which would be active on last page only. This footer will contain my informations and perhaps, some copyrights on my document.

It will be as wide as my page width, like the footer of these several pages :

A colored band which can be modified easily... Is this possible ? Can you help me please ?

share|improve this question
    
Welcome to TeX.SX! –  Papiro Jun 24 '13 at 10:47
    
Hi Nayou and welcome to the site. It's certainly possible to do that. But can you be more specific about what you want? Maybe post the contents of a small .tex file that we can use as a starting point? –  John Wickerson Jun 24 '13 at 10:51
    
@JohnWickerson : Of course yes. That's how my .tex begins : link –  Nayou Jun 24 '13 at 11:04
    
Do you search \vfill? –  moose Jun 24 '13 at 12:26
    
You can define a new heading and use it on the last page with \thispagestyle{foo}. –  Sigur Jun 24 '13 at 12:59

4 Answers 4

up vote 4 down vote accepted

This can be easily done with the background package; the package is loaded with the pages=some option, and then \BgThispage is used for the page where the declared material should appear:

\documentclass[a4paper]{book}
\usepackage[pages=some]{background}
\usepackage{tikzpagenodes}
\usepackage{lipsum}

\backgroundsetup{
  scale=1,angle=0,color=black,
  contents={%
  \tikz[remember picture,overlay]{
    \draw[fill=gray!10,ultra thick,draw=gray,rounded corners] 
    ([yshift=120pt,xshift=5pt]current page.south west) 
    rectangle 
    ([yshift=5pt,xshift=-5pt]current page.south east);
    \node[anchor=north west,inner sep=0pt,text width=.3\paperwidth,align=left] at ([yshift=-20pt,xshift=10pt]current page.south west|-current page text area.south west) {Some information \\ Additional information \\ Some articles};
    \node[anchor=north,inner sep=0pt,text width=.3\paperwidth,align=left] at ([yshift=-20pt,xshift=-25pt]current page text area.south) {Some information \\ Additional information \\ Some articles};
    \node[anchor=north east,inner sep=0pt,text width=.3\paperwidth,align=left] at ([yshift=-20pt,xshift=-10pt]current page.south east|-current page text area.south east) {Some information \\ Additional information \\ Some articles};
  }
  }
}

\begin{document}

\lipsum[1-4]% regular pages
\clearpage\thispagestyle{empty}\BgThispage
\lipsum[1-4]

\end{document}

enter image description here

Since some calculations are involved, the code needs two or three runs to stabilize.

Another variant:

\documentclass[a4paper]{book}
\usepackage[pages=some]{background}
\usepackage{tikzpagenodes}
\usepackage{lipsum}

\backgroundsetup{
  scale=1,angle=0,color=black,
  contents={%
  \tikz[remember picture,overlay]{
    \fill[gray!70,ultra thick] 
    ([yshift=120pt]current page.south west) 
    rectangle 
    (current page.south east);
    \node[anchor=north west,inner sep=0pt,text width=.3\paperwidth,align=left] at ([yshift=-20pt,xshift=10pt]current page.south west|-current page text area.south west) {Some information \\ Additional information \\ Some articles};
    \node[anchor=north,inner sep=0pt,text width=.3\paperwidth,align=left] at ([yshift=-20pt,xshift=-25pt]current page text area.south) {Some information \\ Additional information \\ Some articles};
    \node[anchor=north east,inner sep=0pt,text width=.3\paperwidth,align=left] at ([yshift=-20pt,xshift=-10pt]current page.south east|-current page text area.south east) {Some information \\ Additional information \\ Some articles};
  }
  }
}

\begin{document}

\lipsum[1-4]% regular pages
\clearpage\thispagestyle{empty}\BgThispage
\lipsum[1-4]

\end{document}

enter image description here

share|improve this answer
    
Indeed, it needs several runs to work. But the result is very close to the effect that I'm looking for. In LaTeX, is this possible to have a shape filled with a color, and no border ? I'll continue to play with your work Gonzalo. Thanks –  Nayou Jun 25 '13 at 8:44
    
@Nayou please see my updated answer. –  Gonzalo Medina Jun 25 '13 at 14:52
    
Oh, I didn't see it. Okay, so or I was going in the wrong direction or I'm just not good. I'll watch how you've done it. Thanks : your job is exactly what I wanted at first. –  Nayou Jun 26 '13 at 7:30

Using \AtEndDocument is dangerous. It is possible that many pages are output, if \clearpage of \end{document} is reached. Or the last page is already output, before \end{document} is called.

A safer method is using a label:

  • Package zref-abspage provides an absolute page number for the zref referencing system.
  • Package zref-lastpage defines the label LastPage that is put into the .aux file using the hook \AfterLastShipout of package atveryend.
  • The label can be used inside the macros of package fancyhdr to define the head and foot lines.
  • Macro \iffancylastpage hides the internal stuff (asking the label LastPage, if the current page is the last page). In version 2013/02/09 v3.0 of zref-abspage (not yet released) the interface is simplified at the cost of compatibility. Therefore \iffancylastpage is defined both for older and newer versions of zref-abspage.

Example file:

\documentclass{article}
\usepackage[a6paper,landscape]{geometry}

\usepackage{zref-abspage,zref-lastpage}
\makeatletter
\@ifpackagelater{zref-abspage}{2013/02/09}{%
  \newcommand*{\iffancylastpage}{%
    \ifnum\zref@extractdefault{LastPage}{abspage}{-1}=\value{zabspage}%
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
  }%
}{%
  \newcommand*{\iffancylastpage}{%
    \ifnum\zref@extractdefault{LastPage}{abspage}{-1}%
        =\numexpr\value{abspage}+1\relax
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
  }%
}
\makeatother

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\renewcommand*{\headrulewidth}{0pt}
\renewcommand*{\footrulewidth}{.4pt}
\fancyfoot[R]{\thepage}

\fancyfoot[C]{%
  \iffancylastpage{\textbf{LAST PAGE}}{NORMAL PAGE}%
}

\usepackage{lipsum}

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

Result

share|improve this answer

You should include such "end of document" content as part of the \AtEndDocument hook, whether it's setting a page style, or adding a box with content. Here's an example:

enter image description here

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
\fancypagestyle{default}{
  \fancyhf{}% No header/footer
  \fancyfoot[R]{\thepage}% Right footer
  \renewcommand{\headrulewidth}{0pt}% No header rule
  \renewcommand{\footrulewidth}{0.4pt}% A footer rule
}
\fancypagestyle{last-page}{
  \fancyhf{}% No header/footer
  \fancyfoot[C]{\fbox{\makebox[\dimexpr\linewidth-2\fboxsep-2\fboxrule]{Hello world}}}% Centre footer
  \renewcommand{\headrulewidth}{0pt}% No header rule
  \renewcommand{\footrulewidth}{0.4pt}% A footer rule
}
\pagestyle{default}% Default page style
\AtEndDocument{\thispagestyle{last-page}}% Page style at \end{document}
\begin{document}
\section{A section}\lipsum[1-50]
\end{document}

Note that unprocessed floats at the end of the document (if there are any), might cause problems with the placement of the last-page style.


Similarly, you could use

\AtEndDocument{\vfill%
  % Your end-of-document content
}

to insert a vertical fill and place your end-of-document content automatically (whatever it may be). The same condition holds for unprocessed end-of-document floats. If this remains a concern, investigate the functionality of the atveryend package.

share|improve this answer
    
You answered exactly what I needed. Thanks to your solution, I can use my own custom class more easily. It works. Now, how to ask the rectangle to expand sufficiently to fill the width of my page. A simple \vfill doesn't works for that. –  Nayou Jun 24 '13 at 15:13
    
@Nayou: Do you want the box to be in the text block or in the footer? If the former, should the box span from the end of your text to the bottom of the text block? –  Werner Jun 25 '13 at 1:50

Here is a minimal example to show how to define and use a personal header/footer.

Since I don't know if you are using oneside or twoside option on the class, it is better to define both odd and even.

\documentclass{article}
\usepackage{lipsum}
\usepackage[showframe,a5paper]{geometry}
\makeatletter
 \def\ps@myinfo{
 \def\@oddhead{left \hfill center\hfill right}
 \def\@oddfoot{left \hfill center\hfill right}
 \def\@evenhead{left \hfill center\hfill right}
 \def\@evenfoot{left \hfill center\hfill right}
 }
\makeatother

\begin{document}
\lipsum[1]

\newpage    
\pagestyle{myinfo}

\lipsum[2]

\end{document}

Here is the output:

enter image description here

To use a footer with a rectangle, load the package calc and use

\def\@oddfoot{\fbox{\parbox{\textwidth-2\fboxsep}{left\hfill center \hfill right}}}
share|improve this answer
    
Thanks @Sigur, I understand and it works. Now I'll search how to choose the width of this rectangle. Thanks a lot ! NB : Is this possible to use two \documentclass{} at the same time ? Or have I to create my own with the desired properties ? –  Nayou Jun 24 '13 at 14:49
    
You can not use two classes. You can create a .sty file with your personal commands and load it as a package. –  Sigur Jun 24 '13 at 14:53
    
Ok, thanks for the information. –  Nayou Jun 25 '13 at 8:45

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.