2

I want to create a table like this.

Example Table

So I used xcolor to give alternating colors as this.

This is what I got.

enter image description here

Q1 ) Do you know how to generate white vertical rule get the effect shown red ? (I need white borders. I have to keep the tables' size fixed always and have to use may tables like this which goes across the pages.)

Q2) Is it possible to center align 2nd column while keeping same width?

\documentclass[a4paper,10pt]{article}
\ifx\pdfoutput\undefined\else\usepackage{times}\fi
\usepackage[left=1in,top=1in,right=1in,bottom=1in,head=0.5in,foot=0.4in] {geometry}
\usepackage{graphicx}
\usepackage{float}
\floatstyle{plaintop}
\restylefloat{table}
\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage[table]{xcolor}
\usepackage[T1]{fontenc}
\usepackage{longtable}
\definecolor{BackColor}{RGB}{255,245,245}
\definecolor{AnnexColor}{RGB}{220,230,255}
\definecolor{GrayColor}{RGB}{220,220,220}

\let\oldlongtable\longtable
\let\endoldlongtable\endlongtable
\renewenvironment{longtable}{\rowcolors{3}{BackColor}{AnnexColor}\oldlongtable} {
\endoldlongtable}

\begin{document}
\begin{center}
\begin{longtable}{p{4.15in}p{0.85in}}\\
\rowcolor{GrayColor} \textit{\textbf{Link}} & \textit{\textbf{Count}} \\
/AJAX/infotitle.php & 1 \\
/search.php & 1 \\
/artists.php & 1 \\
/product.php & 1 \\
/userinfo.php & 2 \\
/AJAX/infoartist.php & 1 \\
/AJAX/infocateg.php & 1 \\
\end{longtable}
\end{center}
\end{document}

Thanks in advance.

1
  • 1
    just use a preamble of p{4.15in}|>{\centering\arraybackslash}p{0.85in} and put \arrayrulecolor{white} before the table May 9, 2014 at 13:01

1 Answer 1

1

In case it's only that vertical line that has to be white, here is a solution. I slightly improved the vertical spacing in your table with the cellspace package, and replaced you patching longtable with a call to etoolbox and its AtBeginEnvironment command, to have ashorter code. The second column is now centred.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\ifx\pdfoutput\undefined\else\usepackage{times}\fi
\usepackage[left=1in,top=1in,right=1in,bottom=1in,head=0.5in,foot=0.4in] {geometry}
\usepackage{graphicx}
\usepackage{float}
\floatstyle{plaintop}
\restylefloat{table}
\usepackage[dvipsnames,table]{xcolor}
\usepackage{longtable}
\definecolor{BackColor}{RGB}{255,245,245}
\definecolor{AnnexColor}{RGB}{220,230,255}
\definecolor{GrayColor}{RGB}{220,220,220}

\usepackage{etoolbox}
\AtBeginEnvironment{longtable}{\rowcolors{3}{BackColor}{AnnexColor}}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}

\begin{document}

\begin{center}
\begin{longtable}{S{p{4.15in}}! {\color{white}\vrule width1pt}Sc}%
\rowcolor{GrayColor} \textit{\bfseries Link} & \multicolumn{1}{>{\centering}m{0.85in}}{\textit{\bfseries Count}} \\
/AJAX/infotitle.php & 1 \\
/search.php & 1 \\
/artists.php & 1 \\
/product.php & 1 \\
/userinfo.php & 2 \\
/AJAX/infoartist.php & 1 \\
/AJAX/infocateg.php & 1 \\
\end{longtable}
\end{center}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .