以下代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{table}[t]
\caption{Practically Used Deep CNN Networks}
\label{table1}
\begin{center}
\begin{tabular}{c|c|c|c|c}
NET WIT DATASET & CNN layer & in a network & combining from 2 networks & combining from 3 networks
\\ \hline \\
LeNet MNIST & conv1 & 20 & 15 & 15 \\
LeNet MNIST & conv2 & 50 & 59 & 59 \\
AlexNet CIFAR10 &conv1 &24 &15 &16 \\
AlexNet CIFAR10 &conv2 &96 &107 &107 \\
\end{tabular}
\end{center}
\end{table}
\end{document}
如何让列标题变为多行?
答案1
在这里,我定义了一个新命令\thead
,它将标题括在嵌套的tabular
s 中。您必须手动换行。我还添加了一些字体命令,只是为了说明您必须在哪里添加命令来影响标题的所有部分。
另外,我建议你加载包大批,并为行添加一些额外的空间。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array}
\setlength{\extrarowheight}{2pt} % Add space to rows
\newcommand{\thead}[1]{\small\bfseries\begin{tabular}{@{}c@{}}#1\end{tabular}}
\begin{document}
\begin{table}[t]
\caption{Practically Used Deep CNN Networks}
\label{table1}
\begin{center}
\begin{tabular}{@{}c|c|c|c|c@{}}
\thead{NET WIT\\DATASET} & \thead{CNN\\layer} & \thead{in a\\network} & \thead{combining\\ from\\2 networks } & \thead{combining\\from\\3 networks}
\\ \hline
LeNet MNIST & conv1 & 20 & 15 & 15 \\
LeNet MNIST & conv2 & 50 & 59 & 59 \\
AlexNet CIFAR10 & conv1 & 24 & 15 & 16 \\
AlexNet CIFAR10 & conv2 & 96 & 107 & 107 \\
\end{tabular}
\end{center}
\end{table}
\end{document}
答案2
我建议您采用一个tabularx
环境并允许在第 1、4 和 5 列中换行。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}
\newlength\mylen
\settowidth\mylen{AlexNet CIFAR10} % measure width of 1st col.
\begin{document}
\begin{table}[t]
\caption{Practically Used Deep CNN Networks}
\label{table1}
\medskip
\begin{tabularx}{\textwidth}{@{} P{\mylen}|c|c|C|C @{}}
NET WIT DATASET & CNN layer & In a network & Combining from 2 networks & Combining from 3 networks\\
\hline
LeNet MNIST &conv1 & 20 & 15 & 15 \\
LeNet MNIST &conv2 & 50 & 59 & 59 \\
AlexNet CIFAR10 &conv1 & 24 & 15 & 16 \\
AlexNet CIFAR10 &conv2 & 96 & 107 & 107 \\
\end{tabularx}
\end{table}
\end{document}