# Extra space in command created

Consider the following answer given by @egreg which can be found at http://tex.stackexchange.com/a/111043/10898

Why is an extra 6.799999pt space created when you issue a command like

\framecolorbox[\textwidth]{blue}{blue!40}{what do I do here?}


Does it have to do with the frame separation? A simple way out is to issue a command like

\framecolorbox[\dimexpr\textwidth-6.799999pt\relax]{blue}{blue!40}{what do I do here?}


but this seems too trivial as an answer.

-
–  Mike Renfro Aug 4 '14 at 3:39
Why 6.8pt? Because the default width of the line of a framebox -- like that of so many other lines in TeX and LaTeX -- is 0.4pt and because the default value of thee separation between the edge of the framebox and the edge of the text (the parameteter \fboxsep) is 3pt. Thus, 0.4pt+3pt+3pt+0.4pt = 6.8pt. –  Mico Aug 4 '14 at 3:47
Addendum: I should have noted in the earlier comment that the default values of \fboxrule and \fboxsep apply for the "standard" LaTeX document classes, viz., article, report, and book. Some other document classes, no doubt, choose values other than 0.4pt and 3.0pt, respectively. Incidentally, the value of \fboxrule is usually the same as that of arrayrulewidth -- the width of vertical and horizontal lines that occur in array and tabular environments. –  Mico Aug 4 '14 at 3:56

I'd suggest using a different command, say \framecolorbox*, when the padding and the rule thickess shouldn't be taken into account.

\documentclass{article}
\usepackage{xcolor,xparse}

\ExplSyntaxOn
\NewDocumentCommand{\framecolorbox}{soommm}
{% #1 = star
% #2 = width (optional)
% #3 = inner alignment (optional)
% #4 = frame color
% #5 = background color
% #6 = text
\IfValueTF{#2}
{
\IfValueTF{#3}
{
\fcolorbox{#4}{#5}{
\makebox[
\dim_eval:n {#2 \IfBooleanT{#1}{- 2\fboxsep - 2\fboxrule}}
][#3]{#6}
}
}
{
\fcolorbox{#4}{#5}{\makebox[
\dim_eval:n { #2 \IfBooleanT{#1}{- 2\fboxsep - 2\fboxrule}}
]{#6}
}
}
}
{\fcolorbox{#4}{#5}{#6}}
}
\ExplSyntaxOff

\begin{document}

\noindent X\hrulefill X

\noindent\framecolorbox*[\textwidth]{blue}{blue!40}{what do I do here?}

\noindent\framecolorbox*[\textwidth][l]{blue}{blue!40}{what do I do here?}

\noindent\framecolorbox[\textwidth][s]{blue}{blue!40}{what do I do here?}

\end{document}


-

Slightly modified example, had an overfull box of only 0.8 pt (credit to Why isn't \textwidth the width of the text?), now has no overfull box at all (credit to Mico in comments below):

\documentclass{article}
\usepackage{xcolor,xparse}
\usepackage{calc}
\NewDocumentCommand{\framecolorbox}{oommm}
{% #1 = width (optional)
% #2 = inner alignment (optional)
% #3 = frame color
% #4 = background color
% #5 = text
\IfValueTF{#1}%
{%
\IfValueTF{#2}%
{\fcolorbox{#3}{#4}{\makebox[#1 - 2\fboxsep - 2\fboxrule][#2]{#5}}}%
{\fcolorbox{#3}{#4}{\makebox[#1 - 2\fboxsep - 2\fboxrule]{#5}}}%
}%
{\fcolorbox{#3}{#4}{#5}}%
}%

\begin{document}

\noindent\framecolorbox[\textwidth]{blue}{blue!40}{what do I do here?}

\end{document}

-
0.8pt = 2*0.4pt, where 0.4pt is the default value of the width of the line that surrounds the box. –  Mico Aug 4 '14 at 3:51
Adjusting to take that out, too. Thanks. –  Mike Renfro Aug 4 '14 at 3:54
This will behave differently than \framebox, where the specified width doesn't take into account the padding (\fboxsep) and the rules (\fboxrule), but states the natural width of the inner material as for \makebox. –  egreg Aug 4 '14 at 9:30