简体   繁体   English

Latex:多行问题

[英]Latex: issue with Multirow

I'm using the multirow package to have multiple elements in the same row.我正在使用多行 package 在同一行中有多个元素。

\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.对于 C 和 C^{inv} 列,只有一个元素(而不是两个),因此我希望单个元素位于行的中心而不是上侧。 How can I do that?我怎样才能做到这一点?

在此处输入图像描述

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}

You can use \multirow{2}{*}{...} to place the content in the centre of the two rows您可以使用\multirow{2}{*}{...}将内容放在两行的中心

Off-topic:无关:

  • there are serve package incompatibilities in your preamble.您的序言中有服务 package 不兼容问题。 You must not ignore such error messages and clean up incompatible packages您不能忽略此类错误消息并清理不兼容的软件包

  • you must not use \mathcal outside math mode.你不能在数学模式之外使用\mathcal An error message will tell you this.一条错误消息会告诉您这一点。 You must not ignore error messages您不能忽略错误消息

  • don't use \resizebox for things that contains text.不要将\resizebox用于包含文本的内容。 If you really must change the size, use an appropriate font size instead如果您确实必须更改大小,请改用适当的字体大小

  • don't use h!不要使用h! as floating specifier.作为浮动说明符。 This will only result in bad float placement.这只会导致错误的浮动位置。 Let latex do what it can do best and use htbp让latex做自己能做的最好的,用htbp

  • don't load the same package multiple times不要多次加载相同的 package


\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}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM