Irregular tables in LaTeX
You could use TikZ
for this. The advantage of TikZ
is that it's very powerful, so you can produce whatever effect you want, providing you have the know-how.
Here is some code.
- The
\def...
lines near the top are for customising the size and colour of the cells. - The table might look wrong if the data in the cells is too long, so you must manually make sure that
\cellwidth
is big enough for your needs. - The data in the table is given in a slightly strange way, with lots of
{
,}
,/
and%
symbols. Make sure you keep to this template when putting in your own data, or it will all go belly up!
Do let me know (in the comments below) if you'd like any clarification.
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\def\cellwidth{40}
\def\bluecellwidth{10}
\def\cellheight{7}
\def\bluecellcolor{blue!20}
\def\yellowcellcolor{yellow}
\def\whitecellcolor{white}
\begin{tikzpicture}[%
x=1mm,%
y=-1mm,%
every node/.style={%
shape=rectangle,
anchor=north west,
outer sep=0mm,
draw=black},
bluecell/.style={%
fill=\bluecellcolor,
minimum height=\cellheight * 2 mm,
minimum width=\bluecellwidth mm},
yellowcell/.style={%
fill=\yellowcellcolor,
minimum height=\cellheight mm,
minimum width=\cellwidth mm},
whitecell/.style={%
fill=\whitecellcolor,
minimum height=\cellheight mm,
minimum width=\cellwidth mm}]
\def\y{0} % Vertical cursor
\foreach \header/\contents in {%
{123}/{%
{1339707619:``value''}/{1.1},
{1339707619:``value''}/{1.11},
{1339707619:``value''}/{0.87}
},%
{456}/{%
{1339707619:``value''}/{40},
{1339707619:``value''}/{111},
{1339707619:``value''}/{144},
{1339707619:``value''}/{222}
},%
{789}/{%
{1339707619:``value''}/{21.345}
}%
}{
\node[bluecell] at (0,\y) {\header};
\foreach [count=\i] \yellowtext/\whitetext in \contents {
\node[yellowcell] at ({\bluecellwidth+(\i-1)*\cellwidth},\y) {\yellowtext};
\node[whitecell] at ({\bluecellwidth+(\i-1)*\cellwidth},\y+\cellheight) {\whitetext};
}
\xdef\y{\y+2*\cellheight} % Move vertical cursor down one row
}
\end{tikzpicture}
\end{document}
Your example could be done like this, losing the fancy formatting, but retaining all the information, as far as I can tell.
\documentclass{scrartcl}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\begin{tabular}{lcccc}
\toprule
& 1339707619:``value'' & 1339817619:``value'' &
1369707619:``value'' & 1369707888:``value''\\
\midrule
123 & 1.1 & 1.11 & 0.87 & \\
456 & 40 & 111 & 144 & 222 \\
789 & 21.345 & & & \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Yes you can using multirow, here is an example:
\documentclass[border=5mm]{standalone}
\usepackage{multirow}
\begin{document}
\begin{tabular}{cc|c|c|c|c|l}
\cline{3-6}
& & \multicolumn{4}{ c| }{Primes} \\ \cline{3-6}
& & 2 & 3 & 5 & 7 \\ \cline{1-6}
\multicolumn{1}{ |c| }{\multirow{2}{*}{Powers} } &
\multicolumn{1}{ |c| }{504} & 3 & 2 & 0 & 1 & \\ \cline{2-6}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{540} & 2 & 3 & 1 & 0 & \\ \cline{1-6}
\multicolumn{1}{ |c }{\multirow{2}{*}{Powers} } &
\multicolumn{1}{ |c| }{gcd} & 2 & 2 & 0 & 0 & min \\ \cline{2-6}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{lcm} & 3 & 3 & 1 & 1 & max \\ \cline{1-6}
\end{tabular}
\end{document}