3

I like my mdframed frames to go into the margin, so that the text is not effected, by using a negative leftmargin and rightmargin. However this results in an

Overfull \hbox (0.43031pt too wide) in paragraph at lines 16--16

I don't want to eliminate all overfull box warnings as I still want to know if there are issues with the text.

So, how do I eliminate this warning just for the frame, but not for the text?

References:

Code:

\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{mdframed}

\mdfdefinestyle{MyStyle}{%
    leftmargin=-5pt,
    rightmargin=-5pt,
    backgroundcolor=yellow!25,
}%

\begin{document}
\begin{mdframed}[style=MyStyle]
    \noindent\lipsum[1]
\end{mdframed}
\end{document}
  • This particular Overfull \hbox message is due to a bad paragraph. Try with \usepackage[latin]{babel} and it will disappear. – egreg Jun 10 '13 at 23:18
  • If you add draft as a class option, you will see that the line ending on magna. is the culprit. – Qrrbrbirlbel Jun 10 '13 at 23:20
6

Overfull \hbox warnings are dependent on the length \hfuzz. Setting this to something long removes them from the output warnings. Consider, for example,

\newcommand{\ignoreoverfullhboxes}{\setlength{\hfuzz}{\maxdimen}}

(or something smaller than \maxdimen; default for \hfuzz is 0.1pt). Issue \ignoreoverfullhboxes wherever needed (and localize its scope within an environment).

Using etoolbox, you can call \ignoreoverfullhboxes at the start of every mdframed environment using

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\AtBeginEnvironment{mdframed}{\ignoreoverfullhboxes}

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.