# Multipage tables - vertical centering in cells

I know there were many topics like this but I read a lot of them and it is impossible to understand them for me or they just dont work. I want ALL cells to be centered vertically. I would also like to know how to change it for example to 'bottom' or 'top', so code should be simple and clear. Also, I would like to be able to change horizontal alignment. Remember, its multipage table.

If my request is impossible to achieve in simple way or I must use again something overcomplicated pls just paste code and i will use it.

Minimal Working Code (and some trash i tried to use):

\documentclass{report}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{adjustbox}
\usepackage{array}
\usepackage{polski}
\usepackage[utf8]{inputenc} %kodowanie znakĂłw, zaleĹĽne od systemu
\usepackage[T1]{fontenc} %poprawne skĹ‚adanie polskich czcionek

\begin{document}
\renewcommand{\arraystretch}{1.5}

\begin{longtable}{|c|c|c|c|c|c|c|} %umozliwia rozszerzenie tabeli do kilku stron
\cline{1-7}
\multicolumn{1}{ |c| }{\multirow{2}{*}{ \parbox[t]{2cm}{Mięśnie} } } &
\multicolumn{5}{ c| }{Palce ręki} & \multicolumn{1}{ |c| }{\multirow{2}{*}{ \parbox[t]{2cm}{Nadgarstek}} } \\ \cline{2-6}
\multicolumn{1}{ |c|  }{} & \parbox[t]{0,9cm}{Kciuk} &
\parbox[t]{1,9cm}{Wskazujący} & Środkowy & Serdeczny & Mały & \multicolumn{1}{ c|  }{} \\ \cline{1-7}
{\parbox[t]{3cm}{\textbf{flexor \\digitorum \\superficialis}\\(zginacz \\powierzchowny \\palców)} } &
$\surd$ &
\adjustbox{valign=m}{ $\surd$} & \multirow{1}{*}{x} & $\surd$ & $\surd$ & $\surd$\\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}
{flexor digitorum profundus\\asd\\asd\\asd\\asd\\asd} } &
x & $\surd$ & $\surd$ & $\surd$ & $\surd$ & $\surd$\\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{extensor \\digitorum} } &
x & $\surd$ & $\surd$ & $\surd$ & $\surd$ & x\\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{flexor \\policis longus} } &
$\surd$ & x & x & x & x & $\surd$\\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{extensor policis longus} } &
$\surd$ & x & x & x & x & $\surd$ \\ \cline{1-7}
\multicolumn{1}{ |l| }{ \parbox[t]{3cm}{pronator teres} }  &
x & x & x & x & x & $\surd$ \\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{flexor \\carpi radialis} } &
x & x & x & x & x & $\surd$ \\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{palmaris longus} } &
x & x & x & x & x & $\surd$ \\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{flexor carpi \\ulnaris} } &
x & x & x & x & x & $\surd$ \\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{pronator \\quadratus} } &
x & x & x & x & x & x\\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{brachioradialis} } &
x & x & x & x & x & x\\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{extensor carpi radialis longus} } &
x & x & x & x & x & $\surd$\\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{extensor carpi radialis brevis} } &
x & x & x & x & x & x\\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{supinator} } &
x & x & x & x & x & x\\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{extensor\\ digiti minimi} } &
x & x & x & x & $\surd$ & x\\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{extensor\\ carpi ulnaris} } &
x & x & x & x & x & x \\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{obductor pollicis longus} } &
x & x & x & x & x & x \\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{extensor pollicis brevis} } &
$\surd$ & x & x & x & x & x \\ \cline{1-7}
\multicolumn{1}{ |l| }{\parbox[t]{3cm}{extensor indicis} } &
x & $\surd$ & x & x & x & x\\ \cline{1-7}
\caption{Aktywność mięśni podczas ruchu palców i nadgarstka \cite{praca_detekcja}}
\end{longtable}

\end{document}


-
For the stacked content in the left column, you can use alignment options on the \parbox. For example, {\parbox[c]{3cm}{\strut\textbf{flexor \\digitorum \\superficialis}\\(zginacz \\powierzchowny \\palców)} } & will make the alignment centered for that row. Using a [b] will give bottom alignment. I added a \strut so that there is adequate spacing above the stack. –  Steven B. Segletes Jan 22 at 16:39
Wow! Thank you very much! I would never thought, the parbox used on the left cell affects all cells in this row.. Mindblow. So simple. And this \strut thing is new to me. Now, if you could give full answer with code i could reward you :) –  marek_maras Jan 22 at 18:49
Also if you have ideas how to make this table better i would like to see this as well :) –  marek_maras Jan 22 at 20:14
I see egreg stepped in during my absence, and that is just as well, as his answer is better than what I would have come up with. –  Steven B. Segletes Jan 22 at 23:38

## 1 Answer

Your input can be vastly simplified:

\documentclass{report}

\usepackage[T1]{fontenc} %poprawne skĹ‚adanie polskich czcionek
\usepackage[utf8]{inputenc} %kodowanie znakĂłw, zaleĹĽne od systemu
\usepackage{polski}

\usepackage{longtable}
\usepackage{array}

\begin{document}

\renewcommand{\arraystretch}{1.5}

\begin{longtable}{|>{\raggedright}m{2.5cm}|c|c|c|c|c|c|}
\hline
\centering Mięśnie & \multicolumn{5}{c|}{Palce ręki} & Nadgarstek \\
\cline{2-6}
& Kciuk & Wskazujący & Środkowy & Serdeczny & Mały & \\
\hline
\textbf{flexor digitorum superficialis} zginacz powierzchowny palców &
$\surd$ & $\surd$ & x & $\surd$ & $\surd$ & $\surd$ \\
\hline
flexor digitorum profundus asd asd asd asd asd &
x & $\surd$ & $\surd$ & $\surd$ & $\surd$ & $\surd$ \\
\hline
extensor digitorum &
x & $\surd$ & $\surd$ & $\surd$ & $\surd$ & x \\
\hline
flexor policis longus &
$\surd$ & x & x & x & x & $\surd$\\
\hline
\caption{Aktywność mięśni podczas ruchu palców i nadgarstka \cite{praca_detekcja}}
\end{longtable}

\end{document}


Note that just declaring the first column as m ensures vertical centering. There's no need to use \parbox in each cell.

For the header, I don't think that \multirow adds clarity; to the contrary, I believe it makes the table worse, but you're the final judge.

Set the width of the first column according to the final text width, so that it doesn't cause overfull lines.

Maybe you want to use $\times$ instead of x as a marking.

-
Nice work, I like it :) I used \parbox to set columns width but your idea of >{\raggedright}m{2.5cm} is much better. \multirow for first row makes tekst centered vertically. Could you tell me, \centering applies to whole table or first row/cell? –  marek_maras Jan 22 at 23:09
@marek_maras That \centering applies only to the cell it's in (which is a paragraph cell). –  egreg Jan 22 at 23:19