latex 多行表格合并后的换行问题 (\multirow) | 您所在的位置:网站首页 › angular表格合并 › latex 多行表格合并后的换行问题 (\multirow) |
如题,latex多行表格合并后如何强制换行 弄了半天才找到改正的办法,参考博客\multirow 表格文字居中(latex强制换行) 基础表格的强制换行是在 \begin{tabular}{c c c c c c c}这一块操作 将c改为 p{2cm} 再加上centering, 如: \begin{tabular}{p{2cm}2}*{ Train B \\ ($sigma=0$)}注,使用\multirow的时候记得加上头文件 \usepackage{multirow} 接下来直接在multirow那一行的代码进行更改: \multirow{2}{2cm}{\centering Train B \\ ($sigma=0$)}其中第一个2代表2行表格合并成一行,2cm代表该列的宽度为2cm (按需更改),\centering目的是是表格内的字居中, \ 代表换行。 同时,将\begin{tabular}那块的代码改回 \begin{tabular}{c c c c c c c}得到的结果如表二,完成更改。 表1,表2的具体代码附上, Table 1 代码 \\begin{table}[!t] \renewcommand{\arraystretch}{1.1} \caption{Simple demo} \centering \label{table:attacks} %\centering \resizebox{\columnwidth}{!}{ \begin{tabular}{p{2cm}2}*{ Train B \\ ($sigma=0$)} & A1 & 0.8119 &0.8118 &0.8130 &0.8095 &0.8115 \\ & A2 &0.8119 &0.8462 &0.8425 &0.8424 &0.8459 \\ \hline \multirow{2}*{ test A\\($sigma=1$)} & A1 & 0.4078 &0.4062 &0.4073 &0.4068 &0.3985\\ & A2 &0.4078 &0.4216 &0.4201 &0.4108 &0.4071\\ \hline\hline \end{tabular} } \end{table} \end{document}table 2代码 \begin{table}[!t] \renewcommand{\arraystretch}{1.1} \caption{Simple demo} \centering \label{table:attacks} %\centering \resizebox{\columnwidth}{!}{ \begin{tabular}{c c c c c c c} \hline\hline \\[-3mm] & $f_r$ & 0\% &10\% &20\% &30\% &40\% \\ \hline \multirow{2}{2cm}{\centering Train B \\ ($sigma=0$)} & A1 & 0.8119 &0.8118 &0.8130 &0.8095 &0.8115 \\ & A2 &0.8119 &0.8462 &0.8425 &0.8424 &0.8459 \\ \hline \multirow{2}{2cm}{\centering test A\\($sigma=1$)} & A1 & 0.4078 &0.4062 &0.4073 &0.4068 &0.3985\\ & A2 &0.4078 &0.4216 &0.4201 &0.4108 &0.4071\\ \hline\hline \end{tabular} } \end{table} \end{document} |
CopyRight 2018-2019 实验室设备网 版权所有 |