I need to incorporate multirow
in the following table, and I keep coming across errors.
I found the following example for a great formatted table with colored cells and rounded corners here.
I have tried to implement it for my own table, which you will see in this MWE
.
\documentclass[10pt, compress]{beamer}
\usepackage{multirow}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{PTSansNarrow}
\usepackage[T1]{fontenc}
\usepackage{adjustbox}
\begin{document}
\begin{tikzpicture}
\clip node (m) [matrix,matrix of nodes,
fill=black!20,inner sep=0pt,
nodes in empty cells,
nodes={minimum height=1cm,minimum width=2.6cm,anchor=center,outer sep=0,font=\sffamily},
row 1/.style={nodes={fill=black,text=white}},
column 1/.style={nodes={fill=gray,text=white,align=right,text width=2.5cm,text depth=0.5ex}},
column 2/.style={text width=4cm,align=center,every even row/.style={nodes={fill=white}}},
%column 3/.style={text width=3cm,align=center,every even row/.style={nodes={fill=white}},},
row 1 column 1/.style={nodes={fill=gray}},
prefix after command={[rounded corners=4mm] (m.north east) rectangle (m.south west)}
] {
& Things Identified \\
1 & \\
2 & A \\
3 & B\\
3 & C\\
4 & D \\
4 & E \\
4 & F \\
5 & G\\
5 & H\\
};
\end{tikzpicture}
}
\end{document}
This MWE
provides me with the below result:
When I try to use multirow
so that I do not repeat category names in Column 1, my presentation does not compile.
Here is the MWE
of the code when I try to implement also multirow
:
UPDATE:
\documentclass[10pt, compress]{beamer}
\usepackage{multirow}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{PTSansNarrow}
\usepackage[T1]{fontenc}
\usepackage{adjustbox}
\newcommand\PutLab[3][]{
\node[inner sep=0.05cm,text=white,font=\sffamily,anchor=east,#1]
at (#2)
{#3};
}
\begin{document}
\begin{frame}
\begin{adjustbox}{max totalsize={1.2\textwidth}{0.8\textheight},center}
\begin{tikzpicture}[ampersand replacement=\&]
\clip node (m)
[
matrix,
matrix of nodes,
fill=black!20,
inner sep=0pt,
nodes in empty cells,
nodes={
minimum height=1cm,
minimum width=2.6cm,
anchor=center,
outer sep=0,
font=\sffamily
},
row 1/.style={
nodes={fill=black,text=white}
},
column 1/.style={
nodes={
fill=gray,
text=white,
align=right,
text width=2.5cm,
text depth=0.5ex}
},
column 2/.style={
text width=4cm,
align=center,
every even row/.style={nodes={fill=white}}
},
column 3/.style={
text width=3cm,
align=center,
every even row/.style={nodes={fill=white}}
},
row 1 column 1/.style={nodes={fill=gray}},
prefix after command={
[rounded corners=4mm]
(m.north east) rectangle (m.south west)
}
]
{
\& Things Identified \\
1 \& \\
2 \& A \\
\& B \\
\& C \\
\& D \\
\& E \\
\& F \\
\& G \\
\& H \\
};
\PutLab{m-4-1.south east}{3}
\PutLab{m-7-1.east}{4}
\PutLab{m-9-1.south east}{5}
\foreach \Valor in {1,2,3,5,8}
\draw[black!70] (m-\Valor-1.south west) -- (m-\Valor-2.south east);
\end{tikzpicture}
\end{adjustbox}
\end{frame}
\end{document}
After resizing the box with \usepackageadjustbox
, as in the updated code right above and implementing @Gonzalo Medina proposal, I have the problem with the lighter gray boxes still being visible in the multirow
column, as such:
I am not sure if this is because the boxes are "overlapping" each other or for some other reason, but how can we eliminate (or cover them)?
\usetikzlibrary{matrix}
line in both examples, otherwise I get a compiler error; 2) I'm not suremultirow
will work in amatrix of nodes
since the matrix of nodes isn't a "real" LaTeX table, but we might be able to fake it with Jake's answer you linked to; 3) As the code is now, the lines that are shown between cells in the left column are just artifacts in my PDF viewer, if I zoom in they go away, so do you want lines between rows in that column?; 4) You are drawing this table with three columns but you only need 2 :-)multirow
MWE
above, it won't compile. 3. The lines between the rows in the left column are fine for the moment, especially because they are marking different "categories". 4. I updated the code in theMWE
above :)