[Tex/LaTex] Vertically center align table data in multirow table

multirowtablesvertical alignment

My MWE is as follows:

\documentclass[conference]{IEEEtran}
% correct bad hyphenation here
\hyphenation{}


\usepackage{array}
\usepackage{tabularx}
\usepackage{subcaption,siunitx,booktabs}
\usepackage[margin=1in]{geometry}
\usepackage{multirow, makecell}
\usepackage{array}
\setlength\extrarowheight{2pt}

\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%

\begin{document}

\begin{table*}
    \begin{subtable}{1\textwidth}
        \centering
        \begin{tabular}{|c|c|c|c|c|c|c|c|p{4cm}|}%{cclcccccc}
            \hline
            \multirow{2}{*}{\shortstack[c]{\textbf{Column}\\ \textbf{one}}} &
            \multirow{2}{*}{\shortstack[c]{\textbf{Column}\\ \textbf{two}}} &
            \multirow{2}{*}{\textbf{Column 3}} &
            \multirow{2}{*}{\textbf{Column 4}} &
            \multirow{2}{*}{\textbf{Column 5}} &
            \multicolumn{3}{c|}{\textbf{Column 6}} & \multirow{2}{*}{\textbf{Column 7}} \\ \cline{6-8}
            & & & & & {\textbf{A}} & {\textbf{B}} & {\textbf{C}}
            & \\
            \hline
             \multirow{3}{*}{aaaaa} & \multirow{3}{*}{\shortstack[l]{Type\\ one}} 
                        & A1       & \cmark & \xmark & CRM1 & FF1 & SFR1 & Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. \\ \cline{3-9}
                    &   & A2& \cmark & \cmark & CRM2 & FiF2 & SiFR2 & Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. \\ \cline{3-9}
                    &   & A3          & \cmark & \xmark & CRM3 & FiF3 & SiFR3 & Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. \\ \cline{3-9}
           \hline
        \end{tabular}
        \caption{First subtable1}\label{tab:sub_first1}
    \end{subtable}
    \caption{Three simple tables} \label{tab:three_tables}
\end{table*}

\end{document}

The resulting table is as follows:

enter image description here

Since I wanted the column 7 to be wider, I used p{<width>} argument. However, all the text in rest of the cells are now vertically top-aligned now.

So,

  1. Is it possible to vertically center-align them?

  2. The column header "Column 7" should be horizontally center-aligned. Is there a way to apply only to that cell?

Best Answer

  1. using m{...} instead of p{} will centre align your cells

  2. to center align the last column header: \multicolumn{1}{c|}{\multirow{2}{*}{\textbf{Column 7}}}


\documentclass[conference]{IEEEtran}
% correct bad hyphenation here
\hyphenation{}



\usepackage{array}
\usepackage{tabularx}
\usepackage{subcaption,siunitx,booktabs}
\usepackage[margin=1in]{geometry}
\usepackage{multirow, makecell}
\usepackage{array}
\setlength\extrarowheight{2pt}

\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%

\begin{document}

\begin{table*}
    \begin{subtable}{1\textwidth}
        \centering
        \begin{tabular}{|c|c|c|c|c|c|c|c|m{4cm}|}%{cclcccccc}
            \hline
            \multirow[b]{2}{*}{\shortstack[t]{\textbf{Column}\\ \textbf{one}}} &
            \multirow[b]{2}{*}{\shortstack[t]{\textbf{Column}\\ \textbf{two}}} &
            \multirow{2}{*}{\textbf{Column 3}} &
            \multirow{2}{*}{\textbf{Column 4}} &
            \multirow{2}{*}{\textbf{Column 5}} &
            \multicolumn{3}{c|}{\textbf{Column 6}} & \multicolumn{1}{c|}{\multirow{2}{*}{\textbf{Column 7}}} \\ \cline{6-8}
            & & & & & {\textbf{A}} & {\textbf{B}} & {\textbf{C}}
            & \\
            \hline
             \multirow{10}{*}{aaaaa} & \multirow{10}{*}{\shortstack[lb]{Type\\ one}} 
                        & A1       & \cmark & \xmark & CRM1 & FF1 & SFR1 & Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. \\ \cline{3-9}
                    &   & A2& \cmark & \cmark & CRM2 & FiF2 & SiFR2 & Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. \\ \cline{3-9}
                    &   & A3          & \cmark & \xmark & CRM3 & FiF3 & SiFR3 & Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. \\ \cline{3-9}
           \hline
        \end{tabular}
        \caption{First subtable1}\label{tab:sub_first1}
    \end{subtable}
    \caption{Three simple tables} \label{tab:three_tables}
\end{table*}

\end{document}

enter image description here

Related Question