我希望我的 LaTeX 製作的桌子看起來更垂直拉伸,這樣它就不會顯得那麼垂直緊湊。我希望它看起來更像Google文件的等效項(見圖)。我該怎麼做呢?
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array
\begin{center}
\begin{tabularx}{\textwidth}{
>{\raggedright\arraybackslash\hsize=0.348\hsize}X
>{\centering\arraybackslash\hsize=0.1\hsize}X
>{\raggedleft\arraybackslash\hsize=0.138\hsize}X
>{\raggedleft\arraybackslash\hsize=0.138\hsize}X
>{\raggedleft\arraybackslash\hsize=0.138\hsize}X
>{\raggedleft\arraybackslash\hsize=0.138\hsize}X }
\setlength\cellspacetoplimit{6pt}
\setlength\cellspacebottomlimit{6pt}
& & Unrestricted Funds 2019 & Restricted Funds 2019 & Total Funds 2019 & Total Funds 2018\\
& \small{Note} & £ & £ & £ & £\\
\textsc{Income} &&&&&\\
\hspace{3mm} Voluntary Income & \footnotesize{2} & 43,933 & - & 43,933 & 36,196\\
\hspace{3mm} Investment Income & \footnotesize{2} & - & - & - & 31\\
\hspace{3mm} Charitable Activities & \footnotesize{2} & 597 & - & 597 & 530\\ \cmidrule{3-6}
\textsc{Total Income} && 44,530 & - & 44,530 & 36,757\\[10mm]
\textsc{Expenditure} &&&&&\\
\hspace{3mm} Charitable Activities & \footnotesize{3,4,5,6} & 39,359 & - & 39,359 & 28,343\\
\hspace{3mm} Governance Costs & \footnotesize{4} & 412 & - & 412 & 110\\ \cmidrule{3-6}
\textsc{Total Expenditure} && 39,771 & - & 39,771 & 28,453\\[10mm]
\textsc{Net Income (Expenditure)} && 4,759 & - &4,759 & 8,304\\
\textsc{Net Movement in Funds} && 4,759 & - &4,759 & 8,304\\[10mm]
\textsc{Reconciliation of Funds} &&&&&\\
Total Funds Brought Forward && 35,356 & - &35,356 & 27,052\\
Total Funds Carried Forward && 40,115 & - &40,115 & 35,356\\ \cmidrule{3-6}
\end{tabularx}
\end{center}
答案1
您定義了 的值\cellspacetop/bottomlimits
,這很好,因為儲存格內容將垂直居中。但是您沒有載入cellspace
定義這些長度的套件。此外,單元格將具有此垂直填充的列的說明符必須以字母為前綴S
(或C
如果加載siunitx
)。它適用於所有標準說明符,但不適用於X
列類型,必須將其新增至可識別的說明符清單中。
所以這是一個有效的程式碼。我藉此機會簡化了您的程式碼。請注意,您不必array
在加載時加載tabularx
– 後者會為您完成。另外,您對係數的計算\hsize=...
是錯誤的。它們並不完全是比例係數,因為它們必須總計為列總數X
,而是重心座標。
\documentclass{article}
\usepackage{geometry}
\usepackage{tabularx,booktabs, cellspace}
\setlength\cellspacetoplimit{6pt}
\setlength\cellspacebottomlimit{6pt}
\addparagraphcolumntypes{X}
\begin{document}
\begin{center}%\footnotesize
\setlength{\tabcolsep}{4pt}\small
\begin{tabularx}{\textwidth}{
@{} S{>{\raggedright\arraybackslash\hsize=2\hsize}X}
>{\centering\arraybackslash\hsize=0.48\hsize}X
*{4}{>{\raggedleft\arraybackslash\hsize=0.88\hsize}X}}
& &\multicolumn{2}{c}{ Funds 2019 } & \multicolumn{2}{c}{Total} \\[-0.5ex]
\cmidrule(lr){3-4} \cmidrule(lr){5-6}
& & Unrestricted& Restricted & Funds 2019 & Funds 2018\\
& \small{Note} & £ & £ & £ & £\\
\textsc{Income} &&&&&\\
\hspace{3mm} Voluntary Income & \footnotesize{2} & 43,933 & - & 43,933 & 36,196\\
\hspace{3mm} Investment Income & \footnotesize{2} & - & - & - & 31\\
\hspace{3mm} Charitable Activities & \footnotesize{2} & 597 & - & 597 & 530\\ \cmidrule(l){3-6}
\textsc{Total Income} && 44,530 & - & 44,530 & 36,757\\[10mm]
\textsc{Expenditure} &&&&&\\
\hspace{3mm} Charitable Activities & \footnotesize{3,4,5,6} & 39,359 & - & 39,359 & 28,343\\
\hspace{3mm} Governance Costs & \footnotesize{4} & 412 & - & 412 & 110\\ \cmidrule(l){3-6}
\textsc{Total Expenditure} && 39,771 & - & 39,771 & 28,453\\[10mm]
\textsc{Net Income (Expenditure)} && 4,759 & - &4,759 & 8,304\\
\textsc{Net Movement in Funds} && 4,759 & - &4,759 & 8,304\\[10mm]
\textsc{Reconciliation of Funds} &&&&&\\
Total Funds Brought Forward && 35,356 & - &35,356 & 27,052\\
Total Funds Carried Forward && 40,115 & - &40,115 & 35,356\\ \cmidrule(l){3-6}
\end{tabularx}
\end{center}
\end{document}
答案2
設定為\renewcommand{\arraystretch}{1.5}
\documentclass[a4paper]{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
\begin{document}
\renewcommand{\arraystretch}{1.5}
\begin{center}
\begin{tabularx}{\textwidth}{
>{\raggedright\arraybackslash\hsize=0.348\hsize}X
>{\centering\arraybackslash\hsize=0.1\hsize}X
>{\raggedleft\arraybackslash\hsize=0.138\hsize}X
>{\raggedleft\arraybackslash\hsize=0.138\hsize}X
>{\raggedleft\arraybackslash\hsize=0.138\hsize}X
>{\raggedleft\arraybackslash\hsize=0.138\hsize}X }
& & Unrestricted Funds 2019 & Restricted Funds 2019 & Total Funds 2019 & Total Funds 2018\\
& \small{Note} & £ & £ & £ & £\\
\textsc{Income} &&&&&\\
\hspace{3mm} Voluntary Income & \footnotesize{2} & 43,933 & - & 43,933 & 36,196\\
\hspace{3mm} Investment Income & \footnotesize{2} & - & - & - & 31\\
\hspace{3mm} Charitable Activities & \footnotesize{2} & 597 & - & 597 & 530\\ \cmidrule{3-6}
\textsc{Total Income} && 44,530 & - & 44,530 & 36,757\\[10mm]
\textsc{Expenditure} &&&&&\\
\hspace{3mm} Charitable Activities & \footnotesize{3,4,5,6} & 39,359 & - & 39,359 & 28,343\\
\hspace{3mm} Governance Costs & \footnotesize{4} & 412 & - & 412 & 110\\ \cmidrule{3-6}
\textsc{Total Expenditure} && 39,771 & - & 39,771 & 28,453\\[10mm]
\textsc{Net Income (Expenditure)} && 4,759 & - &4,759 & 8,304\\
\textsc{Net Movement in Funds} && 4,759 & - &4,759 & 8,304\\[10mm]
\textsc{Reconciliation of Funds} &&&&&\\
Total Funds Brought Forward && 35,356 & - &35,356 & 27,052\\
Total Funds Carried Forward && 40,115 & - &40,115 & 35,356\\ \cmidrule{3-6}
\end{tabularx}
\end{center}
\end{document}