5

I have a table that I have attempted to set up as follows (contrived example):

% Preview source code

%% LyX 2.3.2-2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=0.25in,bmargin=0.25cm,lmargin=0.25cm,rmargin=0.25cm}
\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage[table]{xcolor} %for use in color links
\usepackage{colortbl}

\makeatother

\usepackage{babel}
\begin{document}
\noindent \begin{flushleft}
\rowcolors{3}{gray!20}{}%
\begin{tabular}{ccccccc}
 &  & \multicolumn{5}{c}{Lorem ipsum dolor sit amet}\tabularnewline
 &  & Header & Header & Header & Header & Header\tabularnewline
\multirow{8}{*}{\cellcolor{white}\rotatebox{90}{Lorem ipsum}} & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
 & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
 & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
 & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
 & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
 & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
 & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
 & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
\end{tabular}\rowcolors{2}{}{}
\par\end{flushleft}
\end{document}

Apologies in advance for this being generated code, but a commenter below asked for a complete compilable example instead of just the tabular snippet that I had had originally posted. Hopefully this will make it clearer, but I apologize in advance if it has obfuscated the problem.

Anyways, this renders as:

Table

As seen, the sideways header that I am using on the left side of the table gets overwritten by the color of the row, interrupting the text.

What I would like to do is have that entire first column containing the left row header be white on all rows, which I tried to do by adding \cellcolor{white} to the multirow cell, but as the image indicates, it only cleared the top gray strip in that cell, and didn't do anything to the rest of the first column.

How can I get the full text of the header to show up correctly?

  • I provided only a snippet because that was all that was relevant. I have now pasted a full sample document as generated by the TeX editor I am using – Mark Mar 10 at 21:33
5

Using \multirow is the cause of your troubles.

\documentclass{article}
\usepackage{graphicx}
\usepackage[table]{xcolor} %for use in color links

\begin{document}

\begin{flushleft}
\begin{tabular}{@{}c}
\rotatebox[origin=c]{90}{Lorem ipsum\hspace{2\dimexpr\ht\strutbox+\dp\strutbox}}
\end{tabular}%
\rowcolors{3}{gray!20}{}%
\begin{tabular}{cccccc}
 & \multicolumn{5}{c}{Lorem ipsum dolor sit amet}\tabularnewline
 & Header & Header & Header & Header & Header\tabularnewline
Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
\end{tabular}\rowcolors{2}{}{}
\end{flushleft}

\end{document}

I have reduced the document to the minimum necessary.

Note that \noindent\begin{flushleft} is nonsense, because it just adds unwanted vertical space (a blank line). Also \par\end{flushleft} is not necessary.

enter image description here

What does the strange \hspace command? It adds the vertical size of the two header rows.

4

In the following code, I have added a \cellcolor{white} command to all the cells that are in a gray row and should actually have a white background. I have also shifted the \multirow command from the first row to the last row and used -8 instead of 8:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=0.25in,bmargin=0.25cm,lmargin=0.25cm,rmargin=0.25cm}
\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}

\usepackage[table]{xcolor}


\begin{document}
\noindent 
\begin{flushleft}
\rowcolors{3}{gray!20}{}%
\begin{tabular}{ccccccc}
 &  & \multicolumn{5}{c}{Lorem ipsum dolor sit amet}\tabularnewline
 &  & Header & Header & Header & Header & Header\tabularnewline
\cellcolor{white} & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
 & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
\cellcolor{white} & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
 & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
\cellcolor{white} & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
 & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
\cellcolor{white} & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
\multirow{-8}{*}{\rotatebox{90}{Lorem ipsum}} & Content & \#\#\# & \#\#\# & \#\#\# & \#\#\# & \#\#\#\tabularnewline
\end{tabular}
\par\end{flushleft}
\end{document}

enter image description here

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.