# Right margin discrepancy between framed and fbox/minipage

Here is an MWE which shows that something is weird in the framed package.

\documentclass{article}
\usepackage{lipsum}
\usepackage{framed}
\setlength{\FrameSep}{3pt}
\setlength{\fboxsep}{3pt}
\begin{document}
\begin{framed}
\noindent\lipsum[2]
\end{framed}

\noindent\fbox{%
\begin{minipage}{1.0\linewidth}
\lipsum[2]
\end{minipage}
}

\end{document}


Why does the framed environment disagree with minipage about where the right margin should be? Is there an easy way to get the two to line up?

(The framed package claims to be a "preproduction version" and its documentation is dated 2007. Could we have new maintainers maybe?)

-

framed does it well. The way you use \fbox, framing over the complete linewidth, exceeds the text width. The minipage has correct width, but \fbox adds to it. This should cause a warning.

As written in the comment below, calculating the width of the minipage would solve it:

\noindent\fbox{%
\begin{minipage}{\dimexpr\linewidth-2\fboxrule-2\fboxsep}%
\textbackslash fbox: \lipsum[1]
\end{minipage}%
}


For illustration, here's a screenshot without that correction, comparing normal text, framed and fboxed text:

-
So would \fbox{\begin{minipage}{\linewidth - 3pt}... work? –  Seamus Mar 5 '11 at 10:55
@Seamus: It works similarly. I would calculate it: \dimexpr\linewidth-2\fboxrule-2\fboxsep. –  Stefan Kottwitz Mar 5 '11 at 11:08