我在正確顯示下表時遇到問題:
\documentclass[12pt]{report}
\usepackage{tabulary}
\usepackage{booktabs}
\usepackage{float,lscape}
\usepackage{longtable}
\usepackage{tabularx}
\makeatletter
\def\hlinewd#1{%
\noalign{\ifnum0=`}\fi\hrule \@height #1 \futurelet
\reserved@a\@xhline}
\makeatother
\usepackage{multirow}
\usepackage{bigstrut}
\begin{table}[htbp]
\centering
\caption{Yearly membership growth for different time periods}
\scriptsize
\begin{tabulary}{\textwidth}{LLLLLLLLLLLLLLLLL}
\hlinewd{1.25pt}
\textbf{a. Time period 1886 - 1892:} & \textbf{} & \textbf{} & & & & & & & & & & & & & & \bigstrut\\
\cline{1-8} \multicolumn{1}{C}{86} & \multicolumn{1}{C}{87} & \multicolumn{1}{C}{88} & \multicolumn{1}{C}{89} & \multicolumn{1}{C}{90} & \multicolumn{1}{C}{91} & \multicolumn{1}{C}{92} & \multicolumn{1}{C}{AVG} & & & & & & & & & \bigstrut\\
\cline{1-8} \multicolumn{1}{C}{485} & \multicolumn{1}{C}{229} & \multicolumn{1}{C}{372} & \multicolumn{1}{C}{401} & \multicolumn{1}{C}{488} & \multicolumn{1}{C}{261} & \multicolumn{1}{C}{444} & \multicolumn{1}{C}{383} & & & & & & & & & \bigstrut\\
\cline{1-8} & & & & & & & & & & & & & & & & \bigstrut[t]\\
\textbf{b. Time period 1911 - 1926:} & \textbf{} & \textbf{} & & & & & & & & & & & & & & \bigstrut[b]\\
\hline
\multicolumn{1}{C}{11} & \multicolumn{1}{C}{12} & \multicolumn{1}{C}{13} & \multicolumn{1}{C}{14} & \multicolumn{1}{C}{15} & \multicolumn{1}{C}{16} & \multicolumn{1}{C}{17} & \multicolumn{1}{C}{18} & \multicolumn{1}{C}{19} & \multicolumn{1}{C}{20} & \multicolumn{1}{C}{21} & \multicolumn{1}{C}{22} & \multicolumn{1}{C}{23} & \multicolumn{1}{C}{24} & \multicolumn{1}{C}{25} & \multicolumn{1}{C}{26} & \multicolumn{1}{C}{AVG} \bigstrut\\
\hline
\multicolumn{1}{C}{338} & \multicolumn{1}{C}{929} & \multicolumn{1}{C}{528} & \multicolumn{1}{C}{1'426} & \multicolumn{1}{C}{-301} & \multicolumn{1}{C}{117} & \multicolumn{1}{C}{375} & \multicolumn{1}{C}{293} & \multicolumn{1}{C}{652} & \multicolumn{1}{C}{2'671} & \multicolumn{1}{C}{1'370} & \multicolumn{1}{C}{544} & \multicolumn{1}{C}{786} & \multicolumn{1}{C}{479} & \multicolumn{1}{C}{440} & \multicolumn{1}{C}{800} & \multicolumn{1}{C}{715} \bigstrut\\
\hlinewd{1.25pt}
\end{tabulary}%
\label{tab:addlabel}%
\end{table}%
結果如下圖所示:
雖然桌子的位置很好,但我不明白為什麼乳膠在從第一組數字開始後,將其餘的全部放在右邊。右側的數字(87, 88, 89, ....)也應向左對齊。我該如何管理這個表?
非常感謝您一如既往的幫助!
答案1
您應該使用tabular
and\multicolumn{17}{l}{...}
作為跨列的條目:
\documentclass[12pt]{report}
\usepackage{booktabs}
\usepackage{caption}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Yearly membership growth for different time periods}
\label{tab:addlabel}
\scriptsize
\addtolength{\tabcolsep}{-1.8pt}
\begin{tabular}{*{17}{c}}
\toprule
\multicolumn{17}{l}{\textbf{a. Time period 1886--1892}} \\
\cmidrule[\lightrulewidth]{1-8}
86 & 87 & 88 & 89 & 90 & 91 & 92 & AVG & & & & & & & & & \\
\cmidrule[\lightrulewidth]{1-8}
485 & 229 & 372 & 401 & 488 & 261 & 444 & 383 & & & & & & & & & \\
\cmidrule[\lightrulewidth]{1-8}
\multicolumn{17}{l}{\textbf{b. Time period 1911--1926}} \\
\midrule
11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 & 20 & 21 & 22 & 23 & 24 & 25 & 26 & AVG \\
\midrule
338 & 929 & 528 & 1426 & $-301$ & 117 & 375 & 293 & 652 & 2671 & 1370 & 544 & 786 &
479 & 440 & 800 & 715 \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[htbp]
\centering
\caption{Yearly membership growth for different time periods}
\label{tab:addlabel-double}
\footnotesize
\addtolength{\tabcolsep}{-3.1pt}
\begin{tabular}{*{17}{c}}
\toprule
\multicolumn{17}{l}{\textbf{a. Time period 1886--1892}} \\
\cmidrule[\lightrulewidth]{1-8}
86 & 87 & 88 & 89 & 90 & 91 & 92 & AVG & & & & & & & & & \\
\cmidrule[\lightrulewidth]{1-8}
485 & 229 & 372 & 401 & 488 & 261 & 444 & 383 & & & & & & & & & \\
\cmidrule[\lightrulewidth]{1-8}
\multicolumn{17}{l}{\textbf{b. Time period 1911--1926}} \\
\midrule
11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 & 20 & 21 & 22 & 23 & 24 & 25 & 26 & AVG \\
\midrule
338 & 929 & 528 & 1426 & $-301$ & 117 & 375 & 293 & 652 & 2671 & 1370 & 544 & 786 &
479 & 440 & 800 & 715 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
不需要\bigstrut
或複雜的程式碼來實作更重的規則。
我提供了該表的兩個版本,第二個使用\footnotesize
.
我是如何計算-3.1pt
修復的?
我在沒有情況下運行了文檔\addtolength
,對於第二種情況,得到了 104.69522pt 的溢出。由於 104.69522/34 約為 3.079,因此我進行了四捨五入。
第一個版本也是如此。
如果您希望第二個標題上方有一些垂直空間,請使用\addlinespace
...
485 & 229 & 372 & 401 & 488 & 261 & 444 & 383 & & & & & & & & & \\
\cmidrule[\lightrulewidth]{1-8}
\addlinespace[\medskipamount]
\multicolumn{17}{l}{\textbf{b. Time period 1911--1926}} \\
\midrule
...
答案2
後面的列都是左對齊的,但第一列非常寬,因為
\textbf{a. Time period 1886 - 1892:}
這會強制列的寬度。也許您打算使用\multicolumn
跨越所有列而不是強制第一列變寬?
tabulary
( 和tabularx
) 不適合這種表,它們透過改變斷線每列中指定的寬度。由於您的列主要由數字資料組成,因此換行符不相關,因此您最好使用標準tabular
。