You can use the m
option provided by the array package to vertically centre the material in table columns. However, you have another problem. Using \\
without a preceding ampersand creates a row with only one column. This is why part of the right edge of the table is missing. Instead, you could use \par
to insert a line break without moving to the next line of the table.
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{|m{5.5cm}|m{12cm}|}
\hline
\large\textbf{Redirection} & \large\textbf{Description} \\
\hline
\verb|> file| & Redirect standard output (stdout) to a file. \\
\hline
\verb|1> file| & Same as \verb|> file|. \verb|1| is the default file descriptor for stdout. \\
\hline
\verb|2> file| & Redirect standard error (stderr) to a file. \verb|2| is the default file descriptor for stderr. \\
\hline
\verb|>> file| & Append stdout to a file. \\
\hline
\verb|2>> file| & Append stderr to a file. \\
\hline
\verb|&> file| & Redirect stdout and stderr to a file. \\
\hline
\verb|>file 2>&1| & Another way to redirect both stdout and stderr to a file. This \textbf{is not} the same as \verb|2>&1 >file|. \textbf{Redirection order matters!} \\
\hline
\verb|> /dev/null| & Discard stdout. \\
\hline
\verb|2> /dev/null| & Discard stderr. \\
\hline
\verb|&> /dev/null| & Discard stdout and stderr. \\
\hline
\verb|< file| & Redirect the contents of the file to the stdin. \\
\hline
\verb+<< EOL+\par
\verb+foo+\par
\verb+bar+\par
\verb+baz+\par
\verb+EOL+
& Redirect a bunch of lines to the stdin. \\
\hline
\end{tabular}
\end{document}
![table](https://i.stack.imgur.com/wLQtY.png)
The array
package provides a m{}
column specifier which is just like p{}
except that, whereas p{}
puts the cell contents in a top-aligned \parbox[t]{}{}
, \m{}
puts it in a centre-aligned \parbox[c]{}{}
. For example:
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{p{.25\linewidth}cm{.25\linewidth}}
this is a very long line of text in a top-aligned parbox & this is horizontally centred & this is a very long line of text in a centre-aligned parbox\\
\end{tabular}
\end{document}
![top and centre aligned columns](https://i.stack.imgur.com/Tlb4V.png)
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 using baseline
. Here, I've used baseline=(init.base)
. Again, adjust as desired. I've also updated the code to use the new syntax \tikzset{}
rather than the deprecated \tikzstyle{}
.
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{tikz}
\usepackage{multirow}
\usepackage{arydshln}
\begin{document}
\newcommand{\especialidade}[1]{%
\tikzset{
block/.style = {
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, baseline=(init.base)]
\node [block] (init) {\textcolor{white}{\textbf{#1}}};
\end{tikzpicture}}
\newsavebox{\mybox}
\sbox\mybox{%
\raisebox{-2.5pt}{\linethickness{0.2mm}\framebox(10,10){}\hspace{3mm}}}
\begin{table}[h!]
\makebox[\linewidth]{
{\renewcommand{\arraystretch}{2}
\setlength{\arrayrulewidth}{0.5mm}
\setlength\tabcolsep{1mm}
\begin{tabular}{
m{0.22\linewidth} m{0\linewidth};{0.5mm/2pt} @{\usebox{\mybox}}
m{0.23\linewidth} m{0\linewidth};{0.5mm/2pt} @{\usebox{\mybox}}
m{0.23\linewidth} m{0\linewidth};{0.5mm/2pt} @{\usebox{\mybox}}
m{0.24\linewidth} m{0\linewidth} @{\usebox{\mybox}}}
\hline\multicolumn{2}{m{0.23\linewidth};{0.5mm/2pt}}{\especialidade{AAA \textsuperscript{A}}}& \hspace{1mm}
AA (111) &&
\multicolumn{2}{m{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}
![adjusted boxes and pictures](https://i.stack.imgur.com/xorrv.png)
But the basic idea of using m{}
and adjusting to the baseline is the same as in the simpler example above.
Best Answer
To get correct spacing, put a
\strut
before and after the display, and give the twoshortdisplayskip
s the same value.You can change the
shortdisplayskip
s according to your needs; negative values are possible, too.