多列表格與紙列對齊

多列表格與紙列對齊

我正在嘗試在我的手稿中建立下表(用 Excel 起草)。 在此輸入影像描述

我正在使用兩個會議的模板(IEEE 和 SPLNCS),所以我像這樣組織我的工作:

├── IEEEtran.cls
├── llncs.cls
├── mainIEEE.tex
├── mainLNCS.tex
├── Introdoction.tex
└── # ... other sections' tex

這樣我就可以在會議格式之間導航mainEEE.texmainLNCS.tex編譯為會議格式。

但是,我很難將該表與這些範本的列對齊(我的文件中的其他表工作正常)。

微量元素: IEEEtran.clsllncs.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}
  1. 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}

在此輸入影像描述

  1. 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支持的包。rotatingmakecell

  • 使用- Withieeetran` 文檔類別:

\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

在此輸入影像描述

相關內容