在 Latex 中定义带有背景颜色的标题
对于一个小项目,我正在尝试一些感觉好像应该是花生的东西,但是相反(嘿,那是法语,从来没有想过我会记住其中的某些部分。无论如何......) 。
问题是,我想要一个乳胶布局,其中页眉和页脚跨越整个页面宽度并具有背景颜色,并且还可以在左侧、中心或右侧有一些元素(就像 fancyhdr 一样)。问题是,如果不搞乱布局的其余部分,我根本无法让它工作。
编辑:添加示例。
这是我尝试过的一个例子。由于背景未跨越页面的整个宽度,因此标题显示不正确。页脚根本不显示。
\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}
\usepackage[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}
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}
\usepackage[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}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 TikZ 将彩色框绝对定位在页面上。请参阅此处的示例。
此示例包括
\thechapter
的使用,因此您可以从那里继续。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.