5

I'm trying to surround a tabular with a thick frame:

\setlength\fboxrule{2pt}
\setlength{\fboxsep}{0pt}
\fcolorbox{black}{gray}{
    \begin{tabular}{@{}p{2cm}|p{2cm}@{}}
        A & B \\ \hline
        C & D \
    \end{tabular}
}

Although I set \fboxsep to 0pt and use @{}, there is still some horizontal margin between the frame and the tabular:

http://flyx.org/files/framedtabular.png

I want the horizontal line to reach the frame at both ends. How can I achieve that?

flyx
  • 2,051

1 Answers1

9

You are a victim of end of line space. Put % as shown in the following code:

\documentclass{article}
\usepackage{xcolor}
\begin{document}
  \setlength\fboxrule{2pt}
\setlength{\fboxsep}{0pt}
\fcolorbox{black}{gray}{%    %% <------- here
    \begin{tabular}{@{}p{2cm}|p{2cm}@{}}
        A & B \\ \hline
        C & D 
    \end{tabular}%   %% <------- here
}
\end{document}

enter image description here

For details on adding % at the end refer to This Q and its A.