开发者

Defining a header with background color in Latex

For a small project I'm trying something that feels as if it should be peanut, but au contraire (Hey, that's french, never thought I'd remember some parts of that. anyway...).

The thing is, I want a latex layout where the header and footer span the entire pagewidth and have a background color, and also can have some elements on the left, center, or right (like with fancyhdr). The thing is, I simply cannot get this to work without screwing up the rest of the layout.

edit: added example.

Here's an example of what I have tried. The header is shown incorrectly since the background doesn't span the whole width of the page. The footer is not shown at all.

\documentclass[10pt,a4paper,notitlepage]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[usenames,dvipsnames]{color}
\usepackage{fancyhdr}
\usepackage{calc}
\usepackage{tikz}
\usepackag开发者_运维百科e[landscape, top=0cm, bottom=3cm]{geometry}

\definecolor{logoGreen}{RGB}{218,226,87}

\newcommand{\HBG}{
    \begin{tikzpicture}[remember picture,overlay]
        \node[yshift=-2cm] at (current page.north west)
        {
            \begin{tikzpicture}[remember picture, overlay]
                \draw[fill=logoGreen] (0,0) rectangle (\paperwidth,2cm);
            \end{tikzpicture}
        };
    \end{tikzpicture}
}

\fancyhead{}
\fancyhead[L]{\HBG}
\fancyhead[C]{\includegraphics[height=1.2cm]{"img/headerimg"}}

\fancyfoot[C]{\includegraphics[height=1.2cm]{"img/footerimg"}}

\fancyhfoffset[]{1in+\hoffset+\oddsidemargin}

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\headheight 3cm
\footskip -2cm

\pagestyle{fancy}

\begin{document}
\section{first section}
content 
\end{document}


You can use TikZ to position coloured boxes absolutely on the page. See an example here.

This example includes usage of \thechapter, so you can probably go on from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜