라텍스 테이블에 경계선이 없습니다.

라텍스 테이블에 경계선이 없습니다.

한 저널에서 Springer 형식으로 Latex Table 코드를 포팅할 때 다시 한 번 경계선이 누락됩니다(이미지 첨부). 라텍스 코드는 다음과 같습니다. 내가 사용한 수동 대신 페이지 너비에 맞게 테두리 누락 및 자동 줄 바꿈에 대한 솔루션을 제안하십시오.\\

\usepackage{adjustbox} 
%\usepackage{tabularx}
\usepackage{tabularx,ragged2e}
\documentclass{sn-jnl}
\begin{document}

    \begin{table*}[!h]
        %\tiny
        \centering
        \small
        \caption{Result}
        \begin{tabular}{|c|c|c|c|}
            \hline
            \multicolumn{1}{|l|}{\begin{tabular}[c]{@{}l@{}}Users Set\\Size (USS)\end{tabular}} & \multicolumn{1}{l|}{\begin{tabular}[c]{@{}l@{}} Range of Users \\ Individual \end{tabular}} & \multicolumn{1}{l|}{\begin{tabular}[c]{@{}l@{}}Index of scalar array \\ for mapping\end{tabular}} & \multicolumn{1}{l|}{\begin{tabular}[c]{@{}l@{}}Transfer \\ Failure\end{tabular}} \\ \hline
            \multirow{6}{*}{6}                                                                        & \multirow{2}{*}{6}                    & 10                                                                                                       & 23                                                                                           \\ \cline{3-4} 
            &                                       & 4                                                                                                      & \textbf{18.3}                                                                                           \\ \cline{2-4} 
            & \multirow{2}{*}{7}                    & 0                                                                                                      & 13.3                                                                                          \\ \cline{3-4} 
            &                                       & 4                                                                                                       & \textbf{33.3}                                                                                           \\ \cline{2-4} 
            & \multirow{2}{*}{7}                    & 1                                                                                                       & 17                                                                                           \\ \cline{3-4} 
            &                                       & 2                                                                                                       & \textbf{66.6}                                                                                           \\ \hline
        \end{tabular}
   \end{table}

\end{document}

여기에 이미지 설명을 입력하세요

답변1

수직선과 관련된 tabularray패키지 siunitx문제가 제거되고 마지막 열의 숫자가 소수점으로 정렬됩니다.

\documentclass{sn-jnl}

\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\begin{document}
    \begin{table*}[ht]
    \caption{Result}
\sisetup{table-format=2.1,
         detect-weight, % <--
         }
\begin{tblr}{hlines, vlines,
             colspec = {X[c] X[1.2,c] X[1.8,c] X[c, si]},
             cell{even}{2} = {r=2}{},
             cell{odd[3]}{Z} = {font=\bfseries},
             row{1} = {guard}
             } 
Users Set Size (USS)
    &   Range of Users Individual
        &   Index of scalar array for mapping
            &   Transfer Failure        \\
\SetCell[r=6]{c}    6
    & 6 & 10& 23                        \\
    &   & 4 & 18.3                      \\
    & 7 & 0 & 13.3                      \\
    &   & 4 & 33.3                      \\
    & 7 & 1 & 17                        \\
    &   & 2 & 66.6                      \\
\end{tblr}
   \end{table*}
\end{document}

여기에 이미지 설명을 입력하세요

답변2

문제는 문서 클래스 sn-jnl(2019/11/18 v0.1, 1333행)가 \let\cline\cmidrule. 그러나 이 시점에서는 \cmidrule패키지가 booktabs로드되지 않았기 때문에 이 시점에서는 아직 정의되지 않았습니다. \cline정의되지 않았기 때문에 오류가 발생합니다 . 이는 실제로 문서 클래스 코드의 버그로 간주되어야 합니다. 사용하기 전에 booktabs패키지를 로드하여 이 버그를 해결할 수 있습니다 ( 이전에는 작동하지 않음 ).\RequirePackage{booktabs}\documentclass\usepackage\documentclass

그러나 이 내장된 버그를 제쳐두고 문서 클래스 작성자는 분명히 사용자가 다음을 사용하기를 원합니다.booktabs 다음과 같은 패키지를 사용하기를 원합니다.수직선을 지원하지 않습니다. 이 패키지에서 제공하는 매크로를 사용하면 \cmidrule세로 규칙을 깨는 세로 간격을 삽입할 수 있습니다. sn-jnl이제 클래스가 별칭으로 설정되므로 테두리 \cline\cmidrule깨집니다.

이 문제를 해결하는 방법에는 두 가지가 있습니다. 첫 번째 방법은 이 패키지 작성자가 의도한 것과 잘 어울리고 패키지에서 제공하는 기능을 수용하는 것입니다 booktabs. 즉, 수직선의 사용을 피하고 \multirows 없이도 사용할 수 있습니다.

\documentclass{sn-jnl}
\begin{document}

    \begin{table*}[!h]
        \centering
        \small
        \caption{Result}
        \begin{tabular}{ c c c c }
            \toprule
            \begin{tabular}{@{}l@{}} Users Set \\ Size (USS) \end{tabular} & 
            \begin{tabular}{@{}l@{}} Range of Users \\ Individual \end{tabular} & 
            \begin{tabular}{@{}l@{}} Index of scalar array \\ for mapping \end{tabular} &
            \begin{tabular}{@{}l@{}} Transfer \\ Failure \end{tabular} \\ 
            \midrule
            6  & 6  & 10  & 23            \\ \cline{3-4} 
               &    & 4   & \textbf{18.3} \\ \cline{2-4} 
               & 7  & 0   & 13.3          \\ \cline{3-4} 
               &    & 4   & \textbf{33.3} \\ \cline{2-4} 
               & 7  & 1   & 17            \\ \cline{3-4} 
               &    & 2   & \textbf{66.6} \\ 
            \bottomrule
        \end{tabular}
    \end{table*}

\end{document}

여기에 이미지 설명을 입력하세요


또 다른 좀 더 해킹적인 방법은 문서 클래스를 로드하기 전에 원본 매크로를 저장 \cline하고 나중에 정의를 복원하는 것입니다 \cline.

\let\clineorig\cline
\documentclass{sn-jnl}
\usepackage{multirow}

\begin{document}

    \begin{table*}[!h]
        \centering
        \small
        \caption{Result}
        \let\cline\clineorig
        \begin{tabular}{|c|c|c|c|}
            \hline
            \begin{tabular}{@{}l@{}} Users Set \\ Size (USS) \end{tabular} & 
            \begin{tabular}{@{}l@{}} Range of Users \\ Individual \end{tabular} & 
            \begin{tabular}{@{}l@{}} Index of scalar array \\ for mapping \end{tabular} & 
            \begin{tabular}{@{}l@{}} Transfer \\ Failure \end{tabular} \\ 
            \hline
            \multirow{6}{*}{6} & \multirow{2}{*}{6} & 10  & 23            \\ \cline{3-4} 
                               &                    & 4   & \textbf{18.3} \\ \cline{2-4} 
                               & \multirow{2}{*}{7} & 0   & 13.3          \\ \cline{3-4} 
                               &                    & 4   & \textbf{33.3} \\ \cline{2-4} 
                               & \multirow{2}{*}{7} & 1   & 17            \\ \cline{3-4} 
                               &                    & 2   & \textbf{66.6} \\ 
        \hline
        \end{tabular}
    \end{table*}

\end{document}

여기에 이미지 설명을 입력하세요

개인적으로 첫 번째 솔루션을 추천하고 싶습니다.


줄 바꿈에 관해서는: 중첩하는 것은 완전히 괜찮지 tabulars만 매크로 안에 배치할 필요는 없습니다 \multicolumn. 이와 관련하여 코드를 단순화했습니다. 또 다른 방법은 줄 바꿈을 허용하는 열 유형을 적용하는 것일 수 있지만 p{}LaTeX에 열 너비를 알려주어야 합니다(예: p{1cm}열 너비가 1cm인 경우).

답변3

{NiceTabular}자세한 내용은 여기에서 대신 을 사용하여 얻는 내용을 참조하세요 {tabular}.

  • 나는 로드했지만 nicematrix클래스 \usepackage{nicematrix}에서 로드 해야 합니다 nicematrix.pgfsn-jnlpgf~ 전에( \documentclass\RequirePackage).

  • \begin{tabular}나는 및 을 (를) 및 (으) end{tabular}로 교체했습니다 .\begin{NiceTabular}\end{NiceTabular}

\RequirePackage{pgf}
\documentclass{sn-jnl}
\usepackage{nicematrix}

\begin{document}

\begin{NiceTabular}{|c|c|c|c|}
    \hline
    \multicolumn{1}{|l|}{\begin{tabular}[c]{@{}l@{}}Users Set\\Size (USS)\end{tabular}} & \multicolumn{1}{l|}{\begin{tabular}[c]{@{}l@{}} Range of Users \\ Individual \end{tabular}} & \multicolumn{1}{l|}{\begin{tabular}[c]{@{}l@{}}Index of scalar array \\ for mapping\end{tabular}} & \multicolumn{1}{l|}{\begin{tabular}[c]{@{}l@{}}Transfer \\ Failure\end{tabular}} \\ \hline
    \multirow{6}{*}{6}                                                                        & \multirow{2}{*}{6}                    & 10                                                                                                       & 23                                                                                           \\ \cline{3-4} 
    &                                       & 4                                                                                                      & \textbf{18.3}                                                                                           \\ \cline{2-4} 
    & \multirow{2}{*}{7}                    & 0                                                                                                      & 13.3                                                                                          \\ \cline{3-4} 
    &                                       & 4                                                                                                       & \textbf{33.3}                                                                                           \\ \cline{2-4} 
    & \multirow{2}{*}{7}                    & 1                                                                                                       & 17                                                                                           \\ \cline{3-4} 
    &                                       & 2                                                                                                       & \textbf{66.6}                                                                                           \\ \hline
\end{NiceTabular}

\end{document}

위 코드의 출력

nicematrix의 환경에서는 가 재정의되기 때문에 (그리고 해당 정의는 에 의해 수행된 cline재정의를 로컬로 덮어쓰기 때문에 ) 규칙이 깨지지 않습니다.\nclinesn-jnl

그러나 {NiceTabular}의 도구를 사용하여 테이블을 구성하는 표준 방법 nicematrix은 다음과 같습니다.

\RequirePackage{pgf}
\documentclass{sn-jnl}
\usepackage{nicematrix}
\usepackage{siunitx}

\begin{document}

\sisetup{table-format = 2.1,detect-weight}

\begin{NiceTabular}{cccS}[hvlines]
\Block[l]{}{Users Set\\ Size (USS)}
& \Block[l]{}{Range of Users\\ Individual}
& \Block[l]{}{Index of scalar array\\ for mapping}
& \Block[l]{}{Transfer\\ Failure} \\
\Block{6-1}{6} & \Block{2-1}{6} & 10 & 23   \\
               &                & 4  & \bfseries 18.3 \\
               & \Block{2-1}{7} & 0  & 13.3 \\
               &                & 4  & \bfseries 33.3 \\
               & \Block{2-1}{7} & 1  & 17   \\
               &                & 2  & \bfseries 66.6 \\
\end{NiceTabular}

\end{document}

두 번째 코드의 출력

관련 정보