Consider the following answer given by @egreg which can be found at https://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.

  • 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.


 {% #1 = star
  % #2 = width (optional)
  % #3 = inner alignment (optional)
  % #4 = frame color
  % #5 = background color
  % #6 = text
          \dim_eval:n {#2 \IfBooleanT{#1}{- 2\fboxsep - 2\fboxrule}}
        \dim_eval:n { #2 \IfBooleanT{#1}{- 2\fboxsep - 2\fboxrule}}


\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?}


enter image description here


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):

 {% #1 = width (optional)
  % #2 = inner alignment (optional)
  % #3 = frame color
  % #4 = background color
  % #5 = text
     {\fcolorbox{#3}{#4}{\makebox[#1 - 2\fboxsep - 2\fboxrule][#2]{#5}}}%
     {\fcolorbox{#3}{#4}{\makebox[#1 - 2\fboxsep - 2\fboxrule]{#5}}}%


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

  • 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
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.