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.

How can I have a table with the following specifications:

  1. The top and bottom lines are bold and all other horizontal and vertical lines are normal.
  2. The whole table lines (including top and bottom lines) are in red color.
  3. The whole table have an yellow background.
share|improve this question
add comment

2 Answers 2

enter image description here

\documentclass{article}

\usepackage{colortbl}

\arrayrulecolor{red}
\def\widehline{%
\noalign{\global\dimen1 \arrayrulewidth
\global\arrayrulewidth8\arrayrulewidth}%
\hline
\noalign{\global\arrayrulewidth\dimen1 }}

\begin{document}

\colorbox{yellow}{%
\begin{tabular}{|l|l|}
\widehline
1&2\\
\hline
aa&bb\\
aaa&bbb\\
\hline
3&4\\
\widehline
\end{tabular}}

\end{document}
share|improve this answer
    
Possibly \fboxsep=0pt? –  egreg Dec 17 '12 at 0:09
    
@egreg, possibly, or possibly the OP likes having a border with the yellow being bigger than the table. As @egreg hints if you want the yellow background tight to the table, locally set \fboxsep to zero. –  David Carlisle Dec 17 '12 at 0:13
    
How can I have vertically centered cells? –  smh Dec 17 '12 at 10:37
    
Well that is a completely different question. Perhaps m column type from the array package. –  David Carlisle Dec 17 '12 at 10:54
add comment

Here's a possibility using the tabu package:

\documentclass{article}
\usepackage{tabu}
\usepackage[table]{xcolor}

\begin{document}

\noindent\begin{tabu}{| l | l | l |}
\taburowcolors1{yellow!90!black..yellow!90!black} 
\taburulecolor{red}
\tabucline[1pt]- 
column1a & column2a & column3a \\
\tabucline- 
column1b & column2b & column3b \\
\tabucline- 
column1c & column2c & column3c \\
\tabucline- 
column1d & column2d & column3d \\
\tabucline[1pt]- 
\end{tabu}

\end{document}

enter image description here

As a personal suggestion, vertical rules are not necessary and your table will look better without them.

share|improve this answer
add comment

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.