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 am trying to make a colored page in LaTeX. But so far, what I have tried colors the entire page. Which I think does not look that good.

\documentclass[10pt,a4paper]{article}
\usepackage{xcolor}
\usepackage{afterpage}
\usepackage{lipsum}
\widowpenalty=300
\clubpenalty=300

\begin{document}

\lipsum[5]

\newpage

\pagecolor{SkyBlue}\afterpage{\nopagecolor}

\lipsum[1]

\newpage

\lipsum[4]

\end{document}

To be able to set the height and width of the colored box would be great. I also have no idea how to make it fit inside of the standard margins.

Example of pageoutput

share|improve this question
    
\pagecolor sets the page background color. You probably want to look at the mdframed package. –  egreg Oct 24 '11 at 16:56
    
I updated the post to clearify what I am looking for =) –  N3buchadnezzar Oct 24 '11 at 17:19
add comment

3 Answers

up vote 3 down vote accepted

can be done with a tabularx:

\documentclass[10pt,a4paper]{article}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{lipsum}
\usepackage{tabularx,xhfill}

\begin{document}

\noindent
\begin{tabularx}{\linewidth}{ X !{\color{white}\vrule width 2pt} X }
\rowcolor{SkyBlue}
\multicolumn{2}{>{\columncolor{SkyBlue}}p{\dimexpr\linewidth-2\tabcolsep\relax}}{%
  \leavevmode\rule[-2ex]{0pt}{6ex}\Large\xrfill{2pt}[white]\sffamily\ 
  Review
  \xrfill{2pt}[white]}\\
%
\rowcolor{SkyBlue}
\lipsum[1] 
&
\lipsum[1]
\end{tabularx}

\end{document}

enter image description here

share|improve this answer
add comment

I'm not sure what exactly you want. You can use \rule together with \textcolor to get a colored rectangle:

\documentclass{article}

\usepackage{xcolor}
\usepackage{lipsum}

\begin{document}
\lipsum

\textcolor{green}{\rule{10cm}{9cm}}

\lipsum
\end{document}

If you want some colored block drawn in the background you can do this using TikZ, when you use the options remember picture,overlay in the page header, or direct after \newpage. If you want to draw the colored box to the text area margins use my recent tikzpagenodes package:

\documentclass{article}
\usepackage{tikzpagenodes}
\usepackage{lipsum}

\newcommand*{\newcoloredpage}[1]{%
    \newpage
    \begin{tikzpicture}[overlay,remember picture]%
        \fill [#1] (current page text area.south west) rectangle (current page text area.north east);
    \end{tikzpicture}%
    \vspace{-2.5\baselineskip}%
    \par
}

\begin{document}
\lipsum

\newcoloredpage{blue}
\section*{Review}
\lipsum[1]

\newpage

\lipsum

\end{document}

If you want to color the background of a paragraph you could use adjustbox with the minipage and bgcolor keys (and maybe margin to add some more margin):

\documentclass{article}

\usepackage{xcolor}
\usepackage{adjustbox}
\usepackage{lipsum}

\begin{document}
\lipsum

\begin{adjustbox}{minipage=\textwidth,bgcolor=blue}
\lipsum[1]
\end{adjustbox}

\lipsum
\end{document}

However, such a paragraph can't be broken across the page. If you need this the framed or better the more modern mdframed package would be the way to go.
I'm working on a TikZ-based decoration package which would be usable here as well, but isn't finished yet.

share|improve this answer
add comment

FWIW, in ConTeXt, you can use \setupbackgrounds to color the page.

\setupbackgrounds[page][background=color, backgroundcolor=blue:2]

will color the whole page blue.

\setupbackgrounds[text][...]

will color the text area (what you want). One can also use

\setupbackgrounds[text][leftmargin][....]

to color the left margin of the text area and so on.

Instead of background=color, one can choose background=... an overlay and then use metapost to draw the background.

share|improve this answer
add comment

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.