當我將寬度從 .7\textwidth 增加到 .8\textwidth 時,巢狀 tabularx 會中斷

當我將寬度從 .7\textwidth 增加到 .8\textwidth 時,巢狀 tabularx 會中斷

我正在嘗試創建一個三層嵌套表。當我將最外層表格的寬度設定為小於 0.7\textwidth 時,它看起來就像我想要的那樣。但是,我想將其放大,使其佔據整個頁面。當我將其更改為 \textwidth 甚至 .8\textwidth 或 .9\textwidth 時,看起來列變得非常窄。我不太確定發生了什麼事!

\documentclass[a4paper,12pt, margin = .5]{article}
\usepackage{tabularx}
\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}
\newcolumntype{A}{>{\hsize=.80\hsize}Y}
\newcolumntype{Z}{>{\hsize=.35\hsize}Y}

\begin{document}


\renewcommand{\baselinestretch}{1.15}
\renewcommand{\baselinestretch}{1.15}
\begin{table}
\begin{tabularx}{.72\textwidth}{|Z|Y|}
    \hline
    \textbf{Analysis} & \textbf{Factors} \\

    \hline
    &   \\

    \textbf{Gender Generic Referents}
    & {\begin{tabularx}{.5\textwidth}{|A|Y|Y|}
            \cline{1-3}
            & \textbf{Binary} & \textbf{Non-binary}\\ \cline{1-3}

            \textbf{Ambig} & she-he & she-he\\ \cline{1-3}
            \textbf{Unambig} & incongruent-congruent & incongruent-congruent\\ \cline{1-3}          
    \end{tabularx}} \\
    & \\
    \hline

    &   \\
    \textbf{Gender Specific Referents}
    & {\begin{tabularx}{.5\textwidth}{|A|Y|Y|}
            \cline{1-3}
            & \textbf{Binary} & \textbf{Non-binary}\\ \cline{1-3}

            \textbf{Ambig} & she-he & she-he\\ \cline{1-3}
            \textbf{Unambig} & incongruent-congruent & incongruent-congruent\\ \cline{1-3}          
    \end{tabularx}} \\
    & \\
    \hline


    &   \\
    \textbf{Number Specific Referents}
    & {\begin{tabularx}{\linewidth}{|A|Y|Y|}
            \cline{1-3}
            & \textbf{Binary} & \textbf{Non-binary}\\ \cline{1-3}

            \textbf{Ambig} 
            & &\\
            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}  

            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}} \\


            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}

            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}\\ \cline{1-3}




            \textbf{Unambig} 
            & &\\
            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}  

            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}} \\


            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}

            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}\\ \cline{1-3}


    \end{tabularx}} \\
    & \\
    \hline

    & \\
    \textbf{Number Generic Referents}
    & {\begin{tabularx}{\linewidth}{|A|Y|Y|}
            \cline{1-3}
            & \textbf{Binary} & \textbf{Non-binary}\\ \cline{1-3}

            \textbf{Ambig} 
            & &\\
            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}  

            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}} \\


            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}

            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}\\ \cline{1-3}




            \textbf{Unambig} 
            & &\\
            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}  

            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}} \\


            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}

            & {\begin{tabularx}{\linewidth}{|Y|Y|}
                    \cline{1-2}
                    Sing & Plur \\ \cline{1-2}
            \end{tabularx}}\\ \cline{1-3}


    \end{tabularx}} \\
    & \\
    \hline

\end{tabularx}
\caption{Analysis Summary (Construal 1)}
\end{table}

\end{document}

在此輸入影像描述 這是我正在嘗試建立的表

答案1

用法tabularx有兩個錯誤。主要的是

\newcolumntype{Y}{>{\small\raggedright\arraybackslash}X}

\newcolumntype{Z}{>{\hsize=.35\hsize}Y}

\begin{tabularx}{.72\textwidth}{|Z|Y|}

完全打破了tabularx列寬計算,因為tabularx將計算實現 0.72\textwidth 總寬度所需的列寬,但隨後您調整其中一列並使其僅為計算寬度的 35%,因此該演算法將永遠無法達到規定的總寬度。

第二個錯誤與巢狀表有關。外部tabularx(即使是為了解決上述問題而修復的)正在動態計算列寬度,但實際的列內容 \begin{tabularx}{.5\textwidth}始終是頁面寬度的一半,無論外部表列的計算寬度如何。

tabularx都是關於調整列內換行的指定寬度,並且這裡幾乎沒有換行,您可以更簡單地使用tabular.有些人建議使用較少的垂直和水平規則,但在這裡我大部分都保留了它們,並且僅顯示使用tabular而不是 的結果tabularx

在此輸入影像描述

\documentclass[a4paper,12pt]{article}%margin = .5
\usepackage{array}
\newcolumntype{P}{>{\raggedright\arraybackslash
 \renewcommand\arraystretch{1}}m{2.45cm}}

\begin{document}


\renewcommand{\baselinestretch}{1.15}

\begin{table}
\centering
\setlength\tabcolsep{4pt}
\begin{tabular}{@{}|l|l|@{}}
    \hline
    \textbf{Analysis} & \textbf{Factors} \\

    \hline

    \textbf{Gender Generic Referents}
    & 
 \renewcommand\arraystretch{1.7}
      \begin{tabular}{@{}l|P|P@{}}
            & \textbf{Binary} & \textbf{Non-binary}\\ \hline

            \textbf{Ambig} & she-he & she-he\\ \hline
            \textbf{Unambig} & incongruent-congruent & incongruent-congruent\\
    \end{tabular} \\
    \hline

    \textbf{Gender Specific Referents}
    &
     \renewcommand\arraystretch{1.7}
      \begin{tabular}{@{}l|P|P@{}}
            & \textbf{Binary} & \textbf{Non-binary}\\ \hline

            \textbf{Ambig} & she-he & she-he\\ \hline
            \textbf{Unambig} & incongruent-congruent & incongruent-congruent\\
    \end{tabular} \\
    \hline


    \textbf{Number Specific Referents}
    &  \renewcommand\arraystretch{1.7}
          \begin{tabular}{@{}l|P|P@{}}
            & \textbf{Binary} & \textbf{Non-binary}\\ \hline

            \textbf{Ambig} 
            & \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
            \end{tabular}  

            \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
            \end{tabular}
            &\begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
            \end{tabular}

             \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
            \end{tabular}\\\hline
            \textbf{Unambig} 
            & \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
            \end{tabular} 

            \begin{tabular}{|l|l|}
                               \hline
                    Sing & Plur \\\hline
           \end{tabular}
&
            \begin{tabular}{|l|l|}

                   \hline
                    Sing & Plur \\\hline
           \end{tabular}

            \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
           \end{tabular}
   \end{tabular} \\
    \hline

    \textbf{Number Generic Referents}
    & \renewcommand\arraystretch{1.7}
              \begin{tabular}{@{}l|P|P@{}}
            & \textbf{Binary} & \textbf{Non-binary}\\ \hline

            \textbf{Ambig} 
            &
                   \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
           \end{tabular}  

            \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
           \end{tabular} &


            \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
           \end{tabular}

            \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
           \end{tabular}\\

\hline
            \textbf{Unambig} 
            & \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
           \end{tabular}  

            \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
           \end{tabular}
            &\begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
           \end{tabular}

            \begin{tabular}{|l|l|}
                   \hline
                    Sing & Plur \\\hline
           \end{tabular}
   \end{tabular} \\
    \hline

\end{tabular}
\caption{Analysis Summary (Construal 1)}
\end{table}

\end{document}

相關內容