Latex表格排版(三个表格并列、单元格内容自动换行)
程序员文章站
2023-12-24 21:48:15
...
1、LaTex实现三个表格并列排版
刚接触LaTeX排版不久,表格排版一直在摸索中前进,代码中可能还存在冗余或者其他问题,欢迎大家指正我的错误.
代码:
\begin{table*}[!htp]
\floatsetup{floatrowsep=qquad,captionskip=10pt} \tabcolsep=8pt
\begin{floatrow}
\begin{minipage}{0.3\linewidth}
\centering
\renewcommand\arraystretch{1.112}
\ttabbox{\caption{Basic feature}}{%
\begin{tabular}[t]{|c|c|c|c|}
\hline
% \begin{minipage}{1cm}\vspace{1mm} \centering Type\vspace{1mm} \end{minipage}
Type & Kenel & stride & Output
\\
\hline
* & * & * & * \\
* & * & * & * \\
\hline
* & * & * & * \\
* & * & * & * \\
\hline
* & * & * & * \\
* & * & * & * \\
* & * & * & * \\
\hline
* & * & * & * \\
* & * & * & * \\
* & * & * & * \\
\hline
\end{tabular}}
\end{minipage}
\begin{minipage}{0.33\linewidth}
\centering
\renewcommand\arraystretch{1.53}
\floatsetup{floatrowsep=qquad,captionskip=8pt}
\begin{floatrow}
\ttabbox{\caption{Rough Classifier}}{%
\begin{tabular}[t]{|c|c|c|c|}
\hline
Type & Kenel & stride & Output
\\
\hline
* & * & * & * \\
* & * & * & * \\
* & * & * & * \\
\hline
* & * & * & * \\
* & * & * & * \\
\hline
* & * & * & * \\
* & * & * & * \\
\hline
\end{tabular}}
\end{floatrow}
\end{minipage}
\begin{minipage}{0.33\linewidth}
\centering
\renewcommand\arraystretch{2.03}
\ttabbox{\caption{Decolorization Network}}{%
\begin{tabular}[t]{|c|c|c|c|}
\hline
Type & Kenel & stride & Output
\\
\hline
* & * & * & * \\
\hline
* & * & * & * \\
\hline
* & * & * & * \\
\hline
* & * & * & * \\
\hline
* & * & * & * \\
\hline
\end{tabular}}
\end{minipage}
\end{floatrow}
\end{table*}
效果如下:
说明:
scalebox{0.9}{} 设置表格的大小,但是不能实现很好
2、设置整个表格的宽度
使用\setlength{\tabcolsep}{ XXXX mm}设置整个表格的宽度:
\begin{table}[!htbp]
\caption{Complex Illumination Between Images}
\begin{center}
\setlength{\tabcolsep}{4mm}{
\begin{tabular}{|c|c|c|}
\hline
* & * & *\\
\hline
* & * & *\\
\hline
* & * & *\\
\hline
* & * & *\\
\hline
* & * & *\\
\hline
\end{tabular}
\label{tab1}}
\end{center}
\end{table}
3、LaTex表格单元格内容自动换行
表格单元格自动换行需要在\begin{tabular}{|p{30pt}|p{30pt}|p{30pt}|p{30pt}|p{30pt}, p{30pt}表示当内容超过30pt时会自动换行。
\begin{table}[!htbp]
\caption{Comparion of Rmse}
\begin{center}
\begin{tabular}{|p{30pt}|p{30pt}|p{30pt}|p{30pt}|p{30pt}|}
\hline
Image & Pouli et al. \cite{b3}(50\%) & Pouli et al. \cite{b3}(100\%) &Piti\'{e} et al. \cite{b10} & Our results\\
\hline
\includegraphics[width=0.5in]{images/13} & 11.7705 & 12.9743 & 12.9317 & 10.4320\\
\hline
\includegraphics[width=0.5in]{images/14} & 11.7705 & 12.9743 & 12.9317 & 10.4320\\
\hline
\includegraphics[width=0.5in]{images/15} & 11.7705 & 12.9743 & 12.9317 & 10.4320\\
\hline
\end{tabular}
\label{tab1}
\end{center}
\end{table}