我正在使用两个会议的模板(IEEE 和 SPLNCS),因此我按如下方式组织我的工作:
├── IEEEtran.cls
├── llncs.cls
├── mainIEEE.tex
├── mainLNCS.tex
├── Introdoction.tex
└── # ... other sections' tex
这样我就可以导航mainEEE.tex
并mainLNCS.tex
编译成会议格式。
但是,我很难将该表与这些模板的列对齐(我的文档中的其他表可以正常工作)。
梅威瑟: IEEEtran.cls和 llncs.cls
%%% Introduction.tex
\section{Introduction}
\lipsum[1]
\begin{table}[ht]
\caption{Some results}
\label{tab:my_label}
\centering
\begin{tabularx}{\linewidth}{l|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\toprule
Mode & \multicolumn{5}{l|}{Precision} & \multicolumn{5}{l|}{Recall} & \multicolumn{5}{l}{F1\-score} \\
\cline{2-15}
& RF & RF-SMOTEd & AdaBoost & SMOTEBoost & DECOC & RF & RF-SMOTEd & AdaBoost & SMOTEBoost & DECOC & RF & RF-SMOTEd & AdaBoost & SMOTEBoost & DECOC \\
\midrule
cat &1&2&3&4&5 &1&2&3&4&5 &1&2&3&4&5\\
\bottomrule
\end{tabularx}
\end{table}
mainLNCS.tex
输出:
\documentclass[runningheads]{llncs}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{tabularx,ragged2e}
\usepackage{lipsum}
\begin{document}
\title{Manuscript Title (SPLNCS) }
\maketitle
\begin{abstract}
The abstract in 150--250 words.
\keywords{keyword1 \and keyword2}
\end{abstract}
\input{Introduction}
%\bibliographystyle{splncs04}
%\bibliography{Bib/references}
\end{document}
mainIEEE.tex
输出:
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{booktabs}
\usepackage{lipsum}
\usepackage{tabularx,ragged2e}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}
\title{Conference Paper Title (IEEEtran)}
\begin{abstract}
This document is a model and instructions for \LaTeX.
This and the IEEEtran.cls ...
\end{abstract}
\begin{IEEEkeywords}
keyword1, keyword2
\end{IEEEkeywords}
\input{Introduction}
\end{document}
答案1
这显示了如何使用旋转标题。请注意使用tabular*
和\extracolsep
来精确匹配列。
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{table}[ht]
\caption{Some results}
\label{tab:my_label}
%\centering
\tabcolsep=0pt
\begin{tabular*}{\linewidth}{@{\extracolsep{0pt plus 1fil}}lccccccccccccccc}
\toprule
Mode & \multicolumn{5}{l}{Precision} & \multicolumn{5}{l}{Recall} & \multicolumn{5}{l}{F1\-score} \\
\midrule
& \rotatebox{90}{RF} & \rotatebox{90}{RF-SMOTEd} & \rotatebox{90}{AdaBoost} &
\rotatebox{90}{SMOTEBoost} & \rotatebox{90}{DECOC} & \rotatebox{90}{RF} &
\rotatebox{90}{RF-SMOTEd} & \rotatebox{90}{AdaBoost} & \rotatebox{90}{SMOTEBoost} &
\rotatebox{90}{DECOC} & \rotatebox{90}{RF} & \rotatebox{90}{RF-SMOTEd} &
\rotatebox{90}{AdaBoost} & \rotatebox{90}{SMOTEBoost} & \rotatebox{90}{DECOC} \\
\midrule
cat &1&2&3&4&5 &1&2&3&4&5 &1&2&3&4&5\\
\bottomrule
\end{tabular*}
\end{table}
\lipsum[2-6]
\end{document}
答案2
不太清楚,你的表格内容是什么。只有一个数字=还是一个字母符号?
如果是上述情况,那么您可以旋转列标题,如@John Kormylo 答案所示
作为对他的答案的补充,这里建议使用由和包
tabularray
支持的包。rotating
makecell
使用
- With
ieeetran` 文档类:
\documentclass[runningheads]{llncs}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{ragged2e}
\usepackage{tabularray}
\begin{document}
\title{Manuscript Title (SPLNCS) }
\maketitle
\begin{abstract}
The abstract in 150--250 words.
%\keywords{keyword1 \and keyword2}
\end{abstract}
\section{Introduction}
\lipsum[11]
\begin{table}[ht]
\caption{Some results}
\label{tab:my_label}
\centering
\settowidth\rotheadsize{SMOTEBoost}
\renewcommand\theadfont{}
\begin{tblr}{hlines, vlines,
colspec = { l *{15}{X[c]} },
cell{2}{2-Z} = {cmd=\rothead}
}
\SetCell[r=2]{c} Mode
& \SetCell[c=5]{c} Precision
& & & & & \SetCell[c=5]{c} Recall
& & & & & \SetCell[c=5]{c} F1\-score
& & & & \\
& RF
& RF-SMOTEd
& AdaBoost
& SMOTEBoost
& DECOC
& RF
& RF-SMOTEd
& AdaBoost
& SMOTEBoost
& DECOC
& RF
& RF-SMOTEd
& AdaBoost
& SMOTEBoost
& DECOC \\
cat & 1 & 2 & 3 & 4 & 5
& 1 & 2 & 3 & 4 & 5
& 1 & 2 & 3 & 4 & 5 \\
\end{tblr}
\end{table}
\end{document}
- 带有
ieeetran
文档类别:
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
%\usepackage[T1]{fontenc}
% ...
\begin{tblr}{hlines, vlines,
colspec = { l *{15}{X[c]} },
colsep=3pt, % <---
cell{2}{2-Z} = {cmd=\rothead}
}
% rest is the same as before