如何使用 Tabularx 讓我的單字轉到表格內容的第二行?

如何使用 Tabularx 讓我的單字轉到表格內容的第二行?

如何讓單字進入第二行而不自動加上“-”?例如:

Example-->Ex- ample

我嘗試過調整桌子長度,但還是不行。我更喜歡使用tabularx

我嘗試過\space,但看起來很奇怪。

\documentclass[12pt,oneside]{book}
\usepackage{tabularx}
\usepackage{booktabs, ragged2e}   

\begin{document}

\begin{table}[h!]
\centering
    \begin{tabularx}{\textwidth}{>{\RaggedRight\arraybackslash}c X c c c c c }
      \toprule
           & & \multicolumn{2}{>{\centering\arraybackslash}p{8em}}{\textbf{95\% Confidence Interval of the Difference}}  &  \textbf{t}
           & \textbf {df} 
           & \textbf {Sig.(2-tailed)}  \\
     \cmidrule{3-4}  
           & & \multicolumn{1}{c}{\textbf{Lower}} &  \multicolumn{1}{c}{\textbf{Upper}} & & &\\
     \midrule
           Pair 1 & Fruit Fruit Example Dataset (AA) - Fruit Fruit Example Dataset (BB) & 34.33\% &  34.33\% & 34.33 & 34.33 & 34.33\\
    \bottomrule
    \end{tabularx}
\end{table}

\end{document}

在此輸入影像描述

答案1

我將按tabularx如下方式重新組織環境:

  • 首先也是最重要的,正如大衛·卡萊爾(David Carlisle)的文章中已經建議的那樣回答,更改>{\RaggedRight\arraybackslash}cc並更改X>{\RaggedRight\arraybackslash}X(如果允許連字符)或>{\raggedright\arraybackslash}X(如果不允許)。

  • 將控制列間空白量的參數 的值減少\tabcolsep三分之一(從預設值 to6pt開始4pt)。

  • 修剪掉第一列左側和右側或最後一列不需要的空白填充。

  • 不要使用黑體字對於標題單元格——不需要產生影響,但它確實佔用了大量稀缺空間。

  • 在標題單元格之一中使用縮寫。

在此輸入影像描述

\documentclass[12pt,oneside]{book}
\usepackage{tabularx,booktabs}   
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcommand\smalltab[1]{%
   \begin{tabular}[t]{@{}c@{}}#1 \end{tabular}}
\begin{document}

\begin{table}[h!]
\setlength\tabcolsep{4pt} % default value: 6pt
%%%\centering
\begin{tabularx}{\textwidth}{@{} c L *{5}{c} @{}}
\toprule
& & \multicolumn{2}{c}{\smalltab{95\% Conf.\ Int.\\ of Difference}}  & $t$ & df & \smalltab{Significance\\(2-tailed)} \\
\cmidrule(lr){3-4}  
& & Lower & Upper \\
\midrule
Pair 1 & Fruit Fruit Example Dataset (AA) -- Fruit Fruit Example Dataset (BB) 
& 34.33\% &  34.33\% & 34.33 & 34.33 & 34.33\\
\bottomrule
\end{tabularx}
\end{table}

\end{document}

答案2

c是單行條目,所以你不能這樣做

>{\RaggedRight\arraybackslash}c

不執行\RaggedRight任何操作,但是您希望第二列X右側參差不齊,因此替換X

>{\RaggedRight\arraybackslash}X

相關內容