Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

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

share|improve this question

1 Answer 1

up vote 12 down vote accepted

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.

share|improve this answer
2  
It's copied from the OP but that \ after D looks wrong. –  David Carlisle Jan 30 at 11:03
    
@DavidCarlisle You have very good eyes. Thanks and corrected. :) –  Harish Kumar Jan 30 at 11:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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