如何讓單字進入第二行而不自動加上“-”?例如:
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}c
為c
並更改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