Hello,
I'm formatting an article, and I'd like a hint to draw a colored box on page, such as in the attached PDF file.
The colored box should cover the page, starting in the left edge and finishing in the right edge, independently of the text width size, in other words, a box which has the same width of the page.
Regards!
Graphics, Figures & Tables ⇒ Colored Box with Width of Paper
Colored Box with Width of Paper
- Attachments
-
- example.pdf
- (110.31 KiB) Downloaded 956 times
Otavio Augusto
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Colored Box with Width of Paper
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Colored Box with Width of Paper
localghost, the attached file, was done using a basic office suite, like LibreOffice. I do not tried nothing because I dont have any idea how to do it.
Otavio Augusto
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Colored Box with Width of Paper
It could be done using
I prefer
TikZ for such things. It provides a
Here's an example, which I posted some time ago on my blog, showing a similar thing, i.e. a rectangle over the page width with a title text. You could take this as a start any modify it. Just tell us if you have any question regarding it.
Compile at least twice to get the correct overlay position. Or click on Open in writeLaTeX above the code box.
Stefan
atbegshi
, eso-pic
and similar packages with a picture
environment.I prefer

current page
node which we can use for drawing, using an overlay.Here's an example, which I posted some time ago on my blog, showing a similar thing, i.e. a rectangle over the page width with a title text. You could take this as a start any modify it. Just tell us if you have any question regarding it.
Compile at least twice to get the correct overlay position. Or click on Open in writeLaTeX above the code box.
Code: Select all
\documentclass[svgnames]{report}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}
\titleformat{\chapter}
{\gdef\chapterlabel{}
\normalfont\sffamily\Huge\bfseries\scshape}
{\gdef\chapterlabel{\thechapter\ }}{0pt}
{\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-3cm] at (current page.north west)
{\begin{tikzpicture}[remember picture, overlay]
\draw[fill=LightSkyBlue] (0,0) rectangle
(\paperwidth,3cm);
\node[anchor=east,xshift=.9\paperwidth,rectangle,
rounded corners=20pt,inner sep=11pt,
fill=MidnightBlue]
{\color{white}\chapterlabel#1};
\end{tikzpicture}
};
\end{tikzpicture}
}
\titlespacing*{\chapter}{0pt}{50pt}{-60pt}
\begin{document}
\tableofcontents
\chapter{Introduction}
Text
\chapter{Main}
\section{Section}
Text
\begin{thebibliography}{99}
\bibitem{Test} test reference
\end{thebibliography}
\end{document}
LaTeX.org admin
Re: Colored Box with Width of Paper
Stefan, I performed a simple adaptation in the Latex Code which you posted, for my purposes and it works perfectly. So useful! Thanks a lot Stefan!!
Otavio Augusto