2

I am working on color table and using code below.

\documentclass[11pt,a4paper]{article}
\usepackage{array,ragged2e}
\usepackage[pdftex]{graphicx}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\usepackage[margin=1.5cm]{geometry}
\usepackage[table]{xcolor}
\usepackage{wrapfig}
\usepackage{color}
\usepackage{framed,color}
\usepackage{comment}
\usepackage{parskip}
\definecolor{shadecolor}{rgb}{1,0.8,0.3}
\definecolor{lightgray}{rgb}{0.9}
\definecolor{yellow}{rgb}{1,0.5,0}

\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}

\usepackage{Sweave}
\begin{document}






\leavevmode 
\newline 
\leavevmode 
\newline 
\begin{mdframed}[roundcorner=10pt,leftmargin=1, rightmargin=1, linecolor=orange,outerlinewidth=1, innerleftmargin=15, innertopmargin=15,innerbottommargin=15] 
\textbf{Detailed Genotype Table} 
\centering 
\rowcolors{1}{}{yellow}
\begin{tabular}{>{\rule{0pt}{.5cm}}c >{\arraybackslash}m{2cm}>{\arraybackslash}m{2cm}>{\arraybackslash}m{6cm} >{\arraybackslash}m{3cm}} 
\hline 
\rowcolor{orange} \textbf{data} &\textbf{dummy} &\textbf{value} &\textbf{rough} &\textbf{text}\\ 
\hline 
rsxx  & CreT  & 17603472, 19141561  & twet  & 17603472, 19141561\\ 
rs7193xx343  & TrT  & 19597491, 21760908  & twer  & 19597491, 21760908\\ 
rxx376333  & CCe  & 2017r3747  & twertw  & 20173747\\ 
\hline 
\leavevmode 
\newline 
\end{tabular} 
\end{mdframed} 
\leavevmode 
\newline 

\leavevmode 
\newline 
\end{document}

There is no colored table? May i know where i am wrong?

enter image description here

5
  • I can't be sure if this is a solution since I have not installed the mdframed and sweave packages, but the definition of lightgray should be \definecolor{lightgray}{rgb}{0.9,0.9,0.9}. Also, the definition of yellow in this example gives actually an orange color.
    – guillem
    Apr 20, 2012 at 9:22
  • @manish: When posting an example like this, you should make sure that it's minimal, i.e. that it does not contain packages or code unrelated to the problem. In this case, the mdframed and sweave packages (and parskip, comment, wrapfig and a few others) have nothing to do with the table.
    – Jake
    Apr 20, 2012 at 9:40
  • This question is very low quality. Your code is not minimal, and doesn't compile. Please read ive-just-been-told-i-have-to-write-a-minimal-example-what-is-that
    – cmhughes
    Apr 20, 2012 at 9:41
  • Just to inform, my above code is part of my complete latex report. I am not aware of which package clash with which one? Regards
    – manish
    Apr 23, 2012 at 1:01
  • An answer is not the appropriate place to post an edit to your question. Instead, please edit your original question to add additional information or clarification.
    – JohnReed
    Apr 23, 2012 at 1:11

1 Answer 1

11

You loaded a lot of packages for your MWE, a lot of which were unnecessary, and a few of which clashed.

The most important package you need to load for a coloured table is the colortbl package.

It was quite hard to tell what you wanted, but here's a stripped-down version of your code that does colour some of the rows. If it's not what you want, please clarify your question.

enter image description here

\documentclass[11pt,a4paper]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{colortbl}

% new colours
\definecolor{shadecolor}{rgb}{1,0.8,0.3}
\definecolor{lightgray}{rgb}{0.9,0.9,0.9}
\definecolor{yellow}{rgb}{1,0.5,0}

\begin{document}

\begin{mdframed}[roundcorner=10pt,leftmargin=1, rightmargin=1, linecolor=orange,outerlinewidth=1, innerleftmargin=15, innertopmargin=15,innerbottommargin=15] 
\textbf{Detailed Genotype Table} 
\centering 
\begin{tabular}{>{\rule{0pt}{.5cm}}c >{\arraybackslash}m{2cm}>{\arraybackslash}m{2cm}>{\arraybackslash}m{6cm} >{\arraybackslash}m{3cm}} 
\hline 
\rowcolor{orange}   \textbf{data} &\textbf{dummy} &\textbf{value} &\textbf{rough} &\textbf{text}\\ 
\hline 
\rowcolor{lightgray}        rsxx  & CreT  & 17603472, 19141561  & twet  & 17603472, 19141561\\ 
                     rs7193xx343  & TrT  & 19597491, 21760908  & twer  & 19597491, 21760908\\ 
                       rxx376333  & CCe  & 2017r3747  & twertw  & 20173747\\ 
\hline 
\end{tabular} 
\end{mdframed} 

\end{document}
3
  • Above example works fine. But i need to make alternate rows colored in table. How can i implement it? I am using \rowcolors{1}{}{yellow}.
    – manish
    Apr 23, 2012 at 1:27
  • @manish: Since the alternating colours aren't part of this question (and you asked a new one about that), you should consider this question answered and mark it as such by clicking the check mark next to the answer.
    – Jake
    Apr 23, 2012 at 5:46
  • Ok, i have already marked it as checked which means already answered But pls reply answer to my previous another question.
    – manish
    Apr 23, 2012 at 7:04

You must log in to answer this question.

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