ext

69 views
Skip to first unread message

Arne

unread,
Nov 20, 2011, 5:58:40 PM11/20/11
to LaTeX Users Group
I am looking for a solution to my problem related to an extra space
indent in a
colorbox that is within another colorbox. Specifically, the
``inside'' color box is
indented about one space from the left boundary of the ``outside''
color box. See the
example code.

\documentclass[letterpaper]{article}
\usepackage[svgnames]{xcolor}
\usepackage{calc}
\usepackage{fancybox}

\begin{document}
\begin{center}
\shadowbox{%
\colorbox{Wheat}{%
\begin{minipage}{12cm}
\colorbox{BurlyWood}{\parbox[t]{\textwidth-\fboxsep}{\textbf{Short
Heading for this
Box}}}\par\vspace{1ex}
\small I am looking for a solution to my problem related to an extra
space indent in a
colorbox that is within another colorbox. Specifically, the
``inside'' color box is
indented about one space from the left boundary of the ``outside''
color box. See the
example code.
\end{minipage}}%
}%
\end{center}

\end{document}

Werner Grundlingh

unread,
Dec 16, 2011, 2:08:40 AM12/16/11
to latexus...@googlegroups.com
Here is a modified version of \shadowbox that corrects the behaviour you mention:

\documentclass[letterpaper]{article}
\usepackage[svgnames]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{fancybox}% http://ctan.org/pkg/fancybox

\makeatletter
\renewcommand{\shadowbox}[1]{%
  \setlength{\@tempdima}{\fboxsep}% store \fboxsep
  \setlength{\fboxsep}{0pt}% remove \fboxsep
  \VerbBox\@shadowbox{\setlength{\fboxsep}{\@tempdima}#1}% restore \fboxsep and print \shadowbox
}
% \shadowsize=4pt
\makeatother

\begin{document}
\begin{center}
  \shadowbox{%
    \colorbox{Wheat}{%
      \begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule-\shadowsize}%
        \colorbox{BurlyWood}{\parbox[t]{\dimexpr\linewidth-2\fboxsep}{\textbf{Short Heading for this Box}}}\par\vspace{1ex}%
        \small I am looking for a solution to my problem related to an extra space indent in a
        colorbox that is within another colorbox.  Specifically, the ``inside'' color box is
        indented about one space from the left boundary of the ``outside'' color box.  See the
        example code.
      \end{minipage}%
    }%
  }%
\end{center}
\end{document}

The idea is to set \fboxsep to 0pt in order to remove the gap around the edges. Then, inside \shadowbox, you reset it to whatever it was before setting it to 0pt. I've also corrected a small calculation error in your interior \colorbox{BurlyWood} \parbox width, as well as the minipage width to make the entire \shadowbox fit _exactly_ within the textblock width. Removing the calc package in lieu of using \dimexpr is your choice.
Reply all
Reply to author
Forward
0 new messages