如何解决在 \documentclass[sn-mathphys-num]{sn-jnl} 中 Latex 中水平制作表格的问题?

如何解决在 \documentclass[sn-mathphys-num]{sn-jnl} 中 Latex 中水平制作表格的问题?

我正在尝试使用 LaTeX 制作如下所示的表格。此外,我应该在每个单元格中插入一段长文本。

在此处输入图片描述

我在两种不同的型号上尝试过,但都存在问题。下面的两张图显示了这些问题。

\RequirePackage{booktabs}
\documentclass[sn-mathphys-num]{sn-jnl}% Math and Physical Sciences Numbered Reference Style 


\usepackage{graphicx}%
\usepackage{multirow}%
\usepackage{amsmath,amssymb,amsfonts}%
\usepackage{amsthm}%
\usepackage{mathrsfs}%
\usepackage[title]{appendix}%
\usepackage{xcolor}%
\usepackage{textcomp}%
\usepackage{manyfoot}%
\usepackage{booktabs}%
\usepackage{algorithm}%
\usepackage{algorithmicx}%
\usepackage{algpseudocode}%
\usepackage{listings}%

\usepackage{nicematrix}
\usepackage{siunitx}

\usepackage[utf8]{inputenc}
\usepackage{rotating}

%\usepackage{subfigure}
%\usepackage{wrapfig}
%\usepackage{tabularx}
\usepackage{color}
\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{adjustbox}
\usepackage{caption}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\newcommand{\key}{\rotatebox{90}}


\begin{document}

\begin{sidewaystable*}
    \renewcommand{\arraystretch}{0.9}   
    \caption {xxxxxxxxxxx} 
    \label{table:literature}
    \centering
    
    \resizebox{1 \textwidth}{!}{
        \begin{tabular}{|c|c|c|c|c|}
            \cline{2-5} 
            \multicolumn{1}{c|}{\cellcolor{white}} & 
            \multirow{1}{*}{\small \bf xxxxx.} &            
            \multirow{1}{*}{\small \bf xxxxxxx} & \multirow{1}{*}{\small \bf xxxxxxx} & \multirow{1}{*}{\small \bf xxxxxx} \\ \hline  &
            
            {\small na1} & {\small na2} & {\small na3} & {\small na4} \\ & 
            {\small na1 } & {\small na2} & {\small na3} & {\small na4 } \\ & 
            {\small na1 } & {\small na2} & {\small na3} & {\small na4 } \\ & 
            {\small na1 } & {\small na2} & {\small na3} & {\small na4 } \\ \cline{2-5}
            
            \multirow{-3}{*}{
                \begin{tikzpicture}[remember picture,overlay]
                    \node[fill,rectangle,top color={white!50!red},bottom color={white!50!red},minimum width=0.64cm,minimum height=3.4cm] (test){\key{\tiny \bf Conventional}};
                \end{tikzpicture}               
            }  

            &
            
            {\small na1} & {\small na2} & {\small na3} & {\small na4} \\ & 
            {\small na1 } & {\small na2} & {\small na3} & {\small na4 } \\ & 
            {\small na1 } & {\small na2} & {\small na3} & {\small na4 } \\ & 
            {\small na1 } & {\small na2} & {\small na3} & {\small na4 } \\ \cline{2-5}
            
        \end{tabular}
        }
\end{sidewaystable*}    




\begin{sidewaystable*}
   \centering
    \renewcommand{\arraystretch}{0.9}   
    \caption {xxxxxxxxxxx} 
    \label{table:literature}
    \sisetup{table-format=2.1,
         detect-weight, % <--
         }  
    \resizebox{1 \textwidth}{!}{
        \begin{tblr}{hlines, vlines,
             colspec = {},
             cell{2,5,8}{2} = {r=3}{},
             cell{2,5,8}{3} = {r=3}{},
             cell{2,5,8}{4} = {r=3}{},
             cell{2,5,8}{5} = {r=3}{},
             %cell{even}{3} = {r=3}{}
             %cell{odd[3]}{Z} = {font=\bfseries},
             row{1} = {guard}
             } 
              & 
             Ref. & 
             Objective &   
             Features/Classification &   
             Evaluation: No. of Images/Best Results \\
            \SetCell[r=6]{c} \rotatebox[origin=c]{90}{Hand-Crafted Features}       
            & \huge naqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq \newline naqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq & \small naqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq \newline naqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq  & naqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq \newline naqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq \newline naqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq & naqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq \newline naqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq  \\
            & na \newline na & na \newline na  & na \newline na & na \newline na  \\
            & na \newline na & na \newline na  & na \newline na & na \newline na  \\
            & na \newline na & na \newline na  & na \newline na & na \newline na  \\
            & na \newline na & na \newline na  & na \newline na & na \newline na  \\
            & na \newline na & na \newline na  & na \newline na & na \newline na  \\
            
    \end{tblr}
        }
\end{sidewaystable*}


\end{document}

上述文档中第一行和第二行代码的输出分别为:

在此处输入图片描述

在此处输入图片描述

如何解决这个问题呢?

@yannisl 我在文件中进行设置后的新代码.cls

\RequirePackage{booktabs}
\documentclass[sn-mathphys-num]{sn-jnl}% Math and Physical Sciences Numbered Reference Style 


\usepackage{graphicx}%
\usepackage{multirow}%
\usepackage{amsmath,amssymb,amsfonts}%
\usepackage{amsthm}%
\usepackage{mathrsfs}%
\usepackage[title]{appendix}%
\usepackage{xcolor}%
\usepackage{textcomp}%
\usepackage{manyfoot}%
\usepackage{booktabs}%
\usepackage{algorithm}%
\usepackage{algorithmicx}%
\usepackage{algpseudocode}%
\usepackage{listings}%

\usepackage{nicematrix}
\usepackage{siunitx}

\usepackage[utf8]{inputenc}
\usepackage{rotating}

%\usepackage{subfigure}
%\usepackage{wrapfig}
%\usepackage{tabularx}
\usepackage{color}
\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{adjustbox}
\usepackage{caption}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\newcommand{\key}{\rotatebox{90}}


\begin{document}

\begin{sidewaystable*}
    \renewcommand{\arraystretch}{0.9}   
     \caption {xxxxxxxxxxxxxxxx} 
    \label{table:literature}
    \centering
    
    \resizebox{0.5 \textwidth}{!}{
        \setlength{\tabcolsep}{15pt}
        \begin{tabular}{|c|c|c|c|c|}
            \cline{2-5} 
            \multicolumn{1}{c|}{\cellcolor{white}} & 
            \fontsize{40}{40}\selectfont\multirow{-1.8}{*}{\bf xxxxxx} & \fontsize{40}{40}\selectfont\multirow{-1.8}{*}{\bf xxxxxx} & \fontsize{40}{40}\selectfont\multirow{-1.8}{*}{\bf xxxxxxx} 
             & \fontsize{40}{40}\selectfont\multirow{-1.8}{*}{\bf xxxxxx} \\ [.75cm] \hline \\     

            &
             & & & \\ &
             &  & \fontsize{25}{25}\selectfont{} &  \\ & 
             \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} & \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} & \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} \\ & 
             \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} &  & \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} \\ &
             & & & \\ & \\ \cline{2-5}
            

            &
            
             &  &  &  \\ & 
             &  &  &  \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}\\ & 
             \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} & \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} & \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} &  \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}\\ & 
            \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} &  & \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} &  \fontsize{25}{25}\selectfont{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}\\ & 
             &  &  & \fontsize{25}{25}\selectfont{} \\ &
             & & & \\ & \\ \cline{2-5}          

            
            & 
            
             &  &  &  \\ & 
            \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont{} &  &  & \fontsize{25}{25}\selectfont{} \\ &
             & & & \\ & \\ \cline{2-5}
            
            & 
             & & & \\ &
             & \fontsize{25}{25}\selectfont{} &  &  \\ & 
            \fontsize{25}{25}\selectfont\multirow{-3.7}{*}{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} \\ & 
            \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} \\ &
             & & & \\ & \\ \cline{2-5}
            
            \multirow{14.5}{*}{
                \begin{tikzpicture}[remember picture,overlay]
                    \node[fill,rectangle,top color={red!12!white},bottom color={white!99!red},minimum width=1.4cm,minimum height=37.8cm] (test){\fontsize{20}{20}\selectfont\key{\bf xxxxxxxxxxx}};
                \end{tikzpicture}               
            } 

            & 
             & & & \\ &
             &  &  & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} \\ &
             & & & \\ & \\ \cline{2-5}

            &  
             & & & \\ &
             &  & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ &
             & & & \\ & \\ \cline{2-5}
            
            &
             & & & \\ &
             &  & \fontsize{25}{25}\selectfont{} &  \\ &             
             &  & \fontsize{25}{25}\selectfont{} &  \\ &           
            \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} \\ &       
            \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} \\ &      
             &  & \fontsize{25}{25}\selectfont{} \\ &
             & & & \\ & \\ \cline{2-5}
            
            &    
             & & & \\ &
             &  & \fontsize{25}{25}\selectfont{} & \\ & 
            \fontsize{25}{25}\selectfont{} &  & \fontsize{25}{25}\selectfont{} &  \\ & 
            \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-6}{*}{} \\ &
             &  & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-6}{*}{} \\ &
             & & & \\ & \\ \cline{2-5}
            
            
            &
             & & & \\ &
             &  & \fontsize{25}{25}\selectfont{} & \\ & 
            \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} &  & \fontsize{25}{25}\selectfont{} \\ &
             & & & \\ & \\ \cline{2-5}
            
           \multirow{12}{*}{
                \begin{tikzpicture}[remember picture,overlay]
                    \node[fill,rectangle,top color={white!99!blue}, bottom color={blue!3!white}, minimum width=1.4cm,minimum height=12.5cm] (test){\fontsize{20}{20}\selectfont\key{\bf xxx}};
                \end{tikzpicture}               
            } 

            &
             & & & \\ &
             & & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont{} &  & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ & 
           \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ & 
           &  & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ &
           & & & \\ & \\ \cline{2-5}

            
            &
             & & & \\ &
             &  & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} &  & \fontsize{25}{25}\selectfont{} & \fontsize{25}{25}\selectfont{} \\ &
             & & & \\ & \\ \cline{2-5}


            &
            & & & \\ &
            &  &  & \fontsize{25}{25}\selectfont{} \\ & 
            &  & \fontsize{25}{25}\selectfont\multirow{-4}{*}{} & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont\multirow{-6}{*}{} & \fontsize{25}{25}\selectfont\multirow{-3.5}{*}{} & \fontsize{25}{25}\selectfont\multirow{-4}{*}{} & \fontsize{25}{25}\selectfont{} \\ & 
            \fontsize{25}{25}\selectfont\multirow{-6}{*}{} & & \fontsize{25}{25}\selectfont\multirow{-4}{*}{} & \fontsize{25}{25}\selectfont{} \\&
            & & & \\ & \\\hline
            
           \multirow{-15}{*} {
                \begin{tikzpicture}[remember picture,overlay]
                    \node[fill,rectangle,top color={white!100!orange}, bottom color={orange!20!white}, minimum width=1.4cm,minimum height=0cm] (test){\fontsize{20}{20}\selectfont\key{\bf xxxx}};
                \end{tikzpicture}               
            } 

            &
            
        \end{tabular}
        }
\end{sidewaystable*}        


\end{document}

答案1

booktabs 包为 LaTeX2e 社区带来了很多好处。模板使用它来排版表格规则。如果不可用,他们会用自己的命令模拟它。将文件第.cls1277、1304、1314 行更改为 show\vskip 0pt而不是\vskip 3ptor \vskip 2pt

如果不旋转,表格看起来还不错。旋转后,它会给你一种出错的感觉。

我不太确定编辑是否乐意接受你所做的这些更改。最好与他们核实一下。如果你决定无论如何都要这样做,最好复制调整后的宏并将其修补到序言中。

也不要使用调整大小。它会使表格字体看起来不正确!

就我个人而言,我不会改变它。如果在印刷版期刊中阅读,读者会旋转书本来阅读表格,而在数字版中,pdf 阅读器也允许您旋转页面。不过,根据经验法则,请尽量避免旋转表格!

在此处输入图片描述

答案2

我不太清楚您到底想要什么,但是这里是您通过使用{NiceTabular}of直接得到的nicematrix

\RequirePackage{booktabs}
\documentclass[sn-mathphys-num]{sn-jnl}% Math and Physical Sciences Numbered Reference Style 

\usepackage{graphicx}%
\usepackage{amsmath,amssymb,amsfonts}%
\usepackage{amsthm}%
\usepackage{mathrsfs}%
\usepackage[title]{appendix}%
\usepackage{xcolor}%
\usepackage{manyfoot}%
\usepackage{booktabs}%
\usepackage{algorithm}%
\usepackage{algorithmicx}%
\usepackage{algpseudocode}%
\usepackage{listings}%

\usepackage{nicematrix}
\usepackage{rotating}
\usepackage{xcolor}

\usepackage{caption}

\begin{document}

\begin{sidewaystable*}
\renewcommand{\arraystretch}{0.9}   
\caption {xxxxxxxxxxx} 
\label{table:literature}
\centering
\begin{NiceTabular}{ccccc}[vlines,corners=NW]
  \Hline \RowStyle{\bfseries}
     & xxxxx. & xxxxxxx & xxxxxxx & xxxxxx \\ 
  \Hline
    \Block[fill=white!50!red]{*-1}{\rotate Conventional}
     & na1 & na2 & na3 & na4 \\ 
     & na1 & na2 & na3 & na4 \\ 
     & na1 & na2 & na3 & na4 \\ 
     & na1 & na2 & na3 & na4 \\ 
  \Hline
     & na1 & na2 & na3 & na4 \\ 
     & na1 & na2 & na3 & na4 \\ 
     & na1 & na2 & na3 & na4 \\ 
     & na1 & na2 & na3 & na4 \\ 
  \Hline
\end{NiceTabular}
\end{sidewaystable*}    

\end{document}

第一个代码的输出


柱子的宽度为 3 厘米的示例。

\RequirePackage{booktabs}
\documentclass[sn-mathphys-num]{sn-jnl}% Math and Physical Sciences Numbered Reference Style 

\usepackage{graphicx}%
\usepackage{amsmath,amssymb,amsfonts}%
\usepackage{amsthm}%
\usepackage{mathrsfs}%
\usepackage[title]{appendix}%
\usepackage{xcolor}%
\usepackage{manyfoot}%
\usepackage{booktabs}%
\usepackage{algorithm}%
\usepackage{algorithmicx}%
\usepackage{algpseudocode}%
\usepackage{listings}%

\usepackage{nicematrix}
\usepackage{rotating}
\usepackage{xcolor}

\usepackage{caption}

\begin{document}

\begin{sidewaystable*}
\renewcommand{\arraystretch}{0.9}   
\caption {xxxxxxxxxxx} 
\label{table:literature}
\centering
\begin{NiceTabular}{cp{3cm}p{3cm}p{3cm}p{3cm}}[vlines,corners=NW]
  \Hline \RowStyle{\bfseries}
     & xxxxx. & xxxxxxx & xxxxxxx & xxxxxx \\ 
  \Hline
    \Block[fill=white!50!red]{*-1}{\rotate Conventional}
     & xxx xxxxx xx xxxx xxx xxxx xxx xxxxxxx xx x x 
     & xx xx, xxxx xxx xxxxxx xxxxxx xx x x x x xxxx 
     & xxxx xx x x x xxx xxxx xxx x xx xx xx 
     & x x x xxxxxx xxx xxxx xxxxxx xxxx xxxxxxxx xxxxx \\ 
  \Hline
     & xxx xxxxx xx xxxx xxx xxxx xxx xxxxxxx xx x x 
     & xx xx, xxxx xxx xxxxxx xxxxxx xx x x x x xxxx  
     & xxxx xx x x x xxx xxxx xxx x xx xx xx 
     & x x x xxxxxx xxx xxxx xxxxxx xxxx xxxxxxxx xxxxx \\ 
  \Hline
\end{NiceTabular}
\end{sidewaystable*}    

\end{document}

第二段代码的输出

相关内容