Latex: issue with Multirow

1k views Asked by At

I'm using the multirow package to have multiple elements in the same row.

\begin{table}[!h]
\centering
\resizebox{1.0\textwidth}{!}{%
    \begin{tabular}{l*{4}{c}|cc|c}
              & \mathcal{D} & $\rho$ & $N_c$ & $N_C^{inv}$ & $C$ & $C^{inv}$ & $Q$\\
    \hline
    \multirow{2}{*}{Mod0} & \num{9.99} & \num{1.36e+1} & \num{3.32} & \num{7.05e+1} & \num{4.69e-3} & \num{6.59e-2} & \num{1} \\
    & \num{-9.10} & \num{3.69e-1} & \num{-1.70e+1} & \num{-6.36e-2} & & &\num{1} \\ \hline
    Mod1 & \num{1.94e+1} & \num{1.60e+1} & \num{8.65e+1} & \num{1.86e+2} & \num{} \\
    \end{tabular}%
}
\end{table}

For the columns C and C^{inv} there is just one element (instead of two) and therefore I would like the single element to be in the centre of the line and not in the upper side. How can I do that?

enter image description here

The packages I'm using:

\documentclass[12pt, a4paper]{article}

\usepackage{siunitx}
\usepackage{enumitem}
\usepackage{verbatim}
\usepackage{multicol}
\usepackage{ dsfont }

\usepackage{xcolor}


\usepackage{movie15}
\usepackage[hidelinks]{hyperref}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mhchem}
\setcounter{MaxMatrixCols}{12}
\usepackage{commath}

\usepackage{graphicx} 
\usepackage{movie15}
\usepackage{hyperref}
\usepackage{wrapfig}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}

\usepackage{float}

\usepackage[margin=2cm,left=2.5cm,includefoot]{geometry}

\usepackage{lipsum}
\usepackage{subfig}
\usepackage{subfigure}


\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyfoot[R]{ \thepage\ }
\renewcommand{\headrulewidth}{1pt}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyfoot[R]{ \thepage\ }
\renewcommand{\headrulewidth}{1pt}
\renewcommand*\listtablename{Elenco Tabelle}
\renewcommand*\contentsname{Indice}

\usepackage{pythontex} 
\usepackage{minted}
1

There are 1 answers

0
samcarter_is_at_topanswers.xyz On BEST ANSWER

You can use \multirow{2}{*}{...} to place the content in the centre of the two rows

Off-topic:

  • there are serve package incompatibilities in your preamble. You must not ignore such error messages and clean up incompatible packages

  • you must not use \mathcal outside math mode. An error message will tell you this. You must not ignore error messages

  • don't use \resizebox for things that contains text. If you really must change the size, use an appropriate font size instead

  • don't use h! as floating specifier. This will only result in bad float placement. Let latex do what it can do best and use htbp

  • don't load the same package multiple times


\documentclass{article}

\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx} 
\usepackage{multirow}
\usepackage{float}
\usepackage[margin=2cm,left=2.5cm,includefoot]{geometry}

\begin{document}

\begin{table}[htbp]
\centering
%\resizebox{1.0\textwidth}{!}{%
    \begin{tabular}{@{}l*{4}{c}|cc|c@{}}
              & $\mathcal{D}$ & $\rho$ & $N_c$ & $N_C^{inv}$ & $C$ & $C^{inv}$ & $Q$\\
    \hline
    \multirow{2}{*}{Mod0} & \num{9.99} & \num{1.36e+1} & \num{3.32} & \num{7.05e+1} & \multirow{2}{*}{\num{4.69e-3}} & \multirow{2}{*}{\num{6.59e-2}} & \num{1} \\
    & \num{-9.10} & \num{3.69e-1} & \num{-1.70e+1} & \num{-6.36e-2} & & &\num{1} \\ \hline
    Mod1 & \num{1.94e+1} & \num{1.60e+1} & \num{8.65e+1} & \num{1.86e+2} & \num{} \\
    \end{tabular}%
%}
\end{table}

\end{document}