[Tex/LaTex] Multirow on a single column

multirowtablesvertical alignment

I have the following table:

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

\begin{document}

\begin{table}
\centering
\footnotesize
\begin{tabular}{lllll}
\toprule
Algorithm & Learner Memory & Production & Interpretation & Hyperparameters\\
\midrule
KNN & Samples (S) & KNN-based & KNN-based & $k$\\
\multirow{2}{*}{PE}  & Prototypes (P) & Discriminative & Nearest & $\alpha$\\
                     &                & Descriptive    &         &         \\
\multirow{2}{*}{AP}  & P + S          & Discriminative & Nearest & /       \\
                     &                & Descriptive    &         &         \\
\multirow{2}{*}{CWP} & P + Counts     & Discriminative & Nearest & $\alpha$\\
                     &                & Descriptive    &         &         \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

As you can see, I use multirow to have two entries in the third column. However, I don't like how the output looks. While the entries in the first column (Algorithm) are centered vertically, the other columns where there is only 1 entry (Learner Memory, Interpretation and Hyperparameters) are aligned at the top, because of the multirow. How can I center these entries as well?

Best Answer

Use makecell. I added some padding between rows:

\documentclass{article}
\usepackage{multirow, makecell}
\usepackage{booktabs}
\def\DisDes{\makecell{Discriminative\\ Descriptive}}

\begin{document}

\begin{table}
  \centering
  \footnotesize
  \renewcommand{\cellalign}{lc}
  \begin{tabular}{lllll}
    \toprule
    Algorithm & Learner Memory & Production & Interpretation & Hyperparameters \\
    \midrule
    KNN & Samples (S) & KNN-based & KNN-based & $k$ \\
    \addlinespace
    PE & Prototypes (P) & \DisDes & Nearest & $\alpha$ \\
    \addlinespace
    AP & P + S & \DisDes & Nearest & / \\
    \addlinespace
    CWP & P + Counts & \DisDes & Nearest & $\alpha$ \\
    \bottomrule
  \end{tabular}
\end{table}

\end{document} 

enter image description here