1

I want a multirow cell to be vertically centered.

This problem is caused by cells that have been forcefully wrapped.

enter image description here

\begin{table*}[!h]
    \caption{Distinguish success rate according to types of variable used in dummy operations.}
    \label{table:success rate}
    \renewcommand{\arraystretch}{1.05}
    \setlength{\tabcolsep}{0.5em}
    \centering
    \begin{tabular}{|c|c|c|}
        \hline
        \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Types of variable used in \\ dummy operations\end{tabular}} & \multicolumn{2}{c|}{Distinguish success rate} \\ \cline{2-3}
        & \begin{tabular}[c]{@{}c@{}}XMEGA128D4 \\ microprocessor\end{tabular} & \begin{tabular}[c]{@{}c@{}}STM32F303 \\ microprocessor\end{tabular} \\ \hline \hline
        Local variable & 99.92\% & ??.??\% \\ \hline
        Global variable & 93.76\% & ??.??\% \\ \hline
        Separated function argument & 99.86\% & ??.??\% \\ \hline
        United function argument & 73.72\% & ??.??\% \\ \hline
    \end{tabular}
\end{table*}
2
  • 1
    Replace \multirow{2}{*} by \multirow{3}{*}.
    – leandriis
    Jul 4, 2019 at 6:54
  • Remove vertical and double horizontal lines and the tabular looks much better.
    – Sveinung
    Jul 4, 2019 at 9:15

2 Answers 2

1

Here are two versions of your table:

enter image description here

\documentclass{article}
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}

\begin{table*}[!h]
    \caption{Distinguish success rate according to types of variable used in dummy operations.}
    \label{table:success rate}
    \renewcommand{\arraystretch}{1.05}
    \setlength{\tabcolsep}{0.5em}
    \centering
    \begin{tabular}{|c|c|c|}
        \hline
        \multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}Types of variable used in \\ dummy operations\end{tabular}} & \multicolumn{2}{c|}{Distinguish success rate} \\ \cline{2-3}
        & \begin{tabular}[c]{@{}c@{}}XMEGA128D4 \\ microprocessor\end{tabular} & \begin{tabular}[c]{@{}c@{}}STM32F303 \\ microprocessor\end{tabular} \\ \hline \hline
        Local variable & 99.92\% & ??.??\% \\ \hline
        Global variable & 93.76\% & ??.??\% \\ \hline
        Separated function argument & 99.86\% & ??.??\% \\ \hline
        United function argument & 73.72\% & ??.??\% \\ \hline
    \end{tabular}
\end{table*}


\begin{table*}[!h]
    \caption{Distinguish success rate according to types of variable used in dummy operations.}
    \label{table:success rate}
    \centering
    \begin{tabular}{lcc}
        \toprule
        \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}Types of variable used in \\ dummy operations\end{tabular}} & \multicolumn{2}{c}{Distinguish success rate in \%} \\ \cmidrule{2-3}
        & \begin{tabular}[c]{@{}c@{}}XMEGA128D4 \\ microprocessor\end{tabular} & \begin{tabular}[c]{@{}c@{}}STM32F303 \\ microprocessor\end{tabular} \\ \midrule
        Local variable & 99.92 & ??.?? \\ 
        Global variable & 93.76 & ??.?? \\ 
        Separated function argument & 99.86 & ??.?? \\ 
        United function argument & 73.72 & ??.?? \\ 
        \bottomrule
    \end{tabular}
\end{table*}

\end{document}
2

A variation of the second example in @Leandriis answer:

enter image description here

  • used is tabularx table environment
  • word "microprocessor" is moved to table caption
  • multirow cell's use = option
\documentclass{article}
\usepackage{booktabs, multirow, tabularx}
\usepackage[skip=1ex]{caption}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{table}[htb]
    \caption{Distinguish success rate according to types of variable used in dummy operations with microprocessors.}
    \label{table:success rate}
    \centering
    \begin{tabularx}{.84\linewidth}{Xcc}
        \toprule
\multirow{2.4}{=}{Types of variable used in dummy operations}
                            & \multicolumn{2}{c}{Distinguish success rate in \%}    \\
        \cmidrule{2-3}
                            & XMEGA128D4    &   STM32F303   \\
        \midrule
Local variable              & 99.92         & ??.??         \\
Global variable             & 93.76         & ??.??         \\
Separated function argument & 99.86         & ??.??         \\
United function argument    & 73.72         & ??.??         \\
        \bottomrule
    \end{tabularx}
\end{table}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .