The black tikz boxes/nodes are not vertically aligned inside the cells. Does anyone know how to do it? Thanks in advance, and please ignore irrelevant code, I know it's not very clean or straightforward!
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[table]{xcolor}
\usepackage{tikz}
\usepackage{multirow}
\usepackage{arydshln}
\begin{document}
\newcommand{\especialidade}[1]{\tikzstyle{block} = [rectangle, fill=black,
text width=0.25\columnwidth, text depth=0mm, text centered, text height=0.30cm, rounded corners]
\begin{tikzpicture}[node distance = 1cm, auto]
\node [block] (init) {\textcolor{white}{\textbf{#1}}};
\end{tikzpicture}}
\begin{table}[h!]
\makebox[\linewidth]{
{\renewcommand{\arraystretch}{2}
\setlength{\arrayrulewidth}{0.5mm}
\setlength\tabcolsep{1mm}
\begin{tabular}{
p{0.22\linewidth} p{0\linewidth};{0.5mm/2pt} @{\linethickness{0.2mm}\framebox(10,10){}\hspace{3mm}}
p{0.23\linewidth} p{0\linewidth};{0.5mm/2pt} @{\linethickness{0.2mm}\framebox(10,10){}\hspace{3mm}}
p{0.23\linewidth} p{0\linewidth};{0.5mm/2pt} @{\linethickness{0.2mm}\framebox(10,10){}\hspace{3mm}}
p{0.24\linewidth} p{0\linewidth} @{\linethickness{0.2mm}\framebox(10,10){}\hspace{3mm}}}
\hline\multicolumn{2}{p{0.23\linewidth};{0.5mm/2pt}}{\especialidade{AAA \textsuperscript{A}}}& \hspace{1mm}
AA (111) &&
\multicolumn{2}{p{0.23\linewidth};{0.5mm/2pt}}{\especialidade{AAA \textsuperscript{A}}}&\hspace{1mm}
Aaaa-\textit{Aaaa} (111)& \\\hline
Aaaaaaa (111) &&\hspace{1mm}
Aaaaaaa (111) &&\hspace{1mm}
AA aaaaa (111) &&\hspace{1mm}
Aaaa-\textit{aaa} (111)& \\
\end{tabular}
}
}
\end{table}
\end{document}
Best Answer
The
array
package provides am{}
column specifier which is just likep{}
except that, whereasp{}
puts the cell contents in a top-aligned\parbox[t]{}{}
,\m{}
puts it in a centre-aligned\parbox[c]{}{}
. For example:Please do not rely on
tabu
. If you wish to use it even though it may break unexpectedly on you, fine. But understand that there are bugs which will be fixed only when the new version breaks your documents anyway.EDIT
In this case, you have complications caused by oversized content which isn't regular text. For the empty boxes, you can use
\raisebox
, I've used-2.5pt
to move the box a bit down. Adjust as desired. For the TikZ pictures, you can adjust the picture relative to the baseline usingbaseline
. Here, I've usedbaseline=(init.base)
. Again, adjust as desired. I've also updated the code to use the new syntax\tikzset{}
rather than the deprecated\tikzstyle{}
.But the basic idea of using
m{}
and adjusting to the baseline is the same as in the simpler example above.