I am using a colorbox (that contains a parbox) inside a framebox.
Inside the parbox there is an itemize environment
I need some paddding around the text so I put fboxsep for the colorbox to 6pt
However I cant seem to get the background color to fill the framebox entirely even though I set the fboxsep of the framebox to 0pt.
There is always space remaining at the left and right hand side as can be seen from the example.
\documentclass[letterpaper,12pt]{article}
\usepackage[usenames,dvipsnames]{xcolor}
\begin{document}
{\setlength{\fboxsep}{0pt}
\centering
\framebox{
\setlength{\fboxsep}{6pt}
\colorbox{red}{\parbox{\textwidth}
{\centering
Some text text text
\begin{itemize}
\item xxxxxxxxxxxxxxxxxxxxxxxxxxx
\item yyyyyyyyyyyyyyyyyyyyyyyyyyy
\item zzzzzzzzzzzzzzzzzzzzzzzzzzz
\end{itemize}
\par}}
}
\par}
\end{document}
Any ideas ?
Best Answer
There were some spurious blank spaces at the end of some lines (I killed them using
%
); also, you need to correct the width for the\parbox
to take into account the padding of thecolorbox
and the width of the rules of the\framebox
:You can use a single
\fcolorbox
instead of a\framebox
and a\colorbox
:Or, even simpler, use
mdframed
ortcolorbox
:or
With both package you can define a dedicated box if this is going to be used multiple times.