1

In the process of creating a beamer template from a PowerPoint template, I am trying to create a tabular environment with colored rows, lines between the rows and specific header and footer styles. Currently I have the layout mixed in an environment that takes care of the alternating rowcolors, but I didn't manage to define the header and footer rows or the style of the separating lines in my environment.

\documentclass{article}

\usepackage[table]{xcolor}

\newenvironment{mytabular}[1]
  {\renewcommand{\arraystretch}{1.2}
  \rowcolors{1}{red!10}{green!30}
  \arrayrulecolor{white}
  \footnotesize
  \begin{tabular}{#1}}
  {\end{tabular}}

\begin{document}

\begin{mytabular}{l!{\textcolor{white}{\vrule width 1pt}}c!{\textcolor{white}{\vrule width 1pt}}r}
  \rowcolor{blue}
      & \textcolor{white}{\textbf{Standard}} & \textcolor{white}{\textbf{Varianz}} \\ \noalign{{\color{white}\hrule height 2pt}}
    x & x & x \\ \noalign{{\color{white}\hrule height 1pt}}
    x & x & x \\ \noalign{{\color{white}\hrule height 1pt}}
    x & x & x \\ \noalign{{\color{white}\hrule height 2pt}}
  \rowcolor{blue} x & x & x
\end{mytabular}

\end{document}

I would like to combine those styles in a way that I can still define the number and alignment of columns, but have the separators fixed.

0

The best I could come up with until now is this:

\newcolumntype{|}{!{\color{white}\vrule width 1pt}}

\newcommand{\ihline}{
 \noalign{{\color{white}\hrule height 1pt}}
}

\newcommand{\iihline}{
  \noalign{{\color{white}\hrule height 2pt}}
}

\newenvironment{mytabular}[1]
{
  \renewcommand{\arraystretch}{1.2}
  \rowcolors{1}{blue}{green}
  \arrayrulecolor{white}
  \footnotesize
  \begin{tabular}{#1}
    \rowcolor{red}}
{\end{tabular}}

This allows the user to define their tables almost like they would usually do

\begin{mytabular}{l|c|r}
    & \textcolor{white}{\textbf{x}} & \textcolor{white}{\textbf{x}} \\ \iihline
  x & x & x \\ \ihline
  x & x & x \\ \ihline
  x & x & x \\ \ihline
  x & x & x
\end{mytabular}

It would be nice to be able to set the font for the header row like I can set the rowcolor, but this is already much better then the version I had in the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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