我从 excel2latex 复制了此表,我希望此表居中、对齐并适合页面边缘。我的代码是:
\documentclass[11pt]{article}
\usepackage{booktabs,siunitx}
\usepackage{graphicx}
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}
\centering
\small
\scalebox{0.4}{
\begin{tabular}{llcclccc}
\textbf{Table 1} & & & & & & & \\
\multicolumn{8}{l}{Charitable Donation Tax Credit Rates1, by Province, 1997 and 2009 (\%)} \\
\midrule
\midrule
& \multicolumn{3}{c@{\quad}}{1997} & & \multicolumn{3}{r@{\quad}}{2009} \\
\cmidrule{2-4}\cmidrule{6-8} & \multicolumn{1}{l}{First \$200 of Donations} & & \multicolumn{1}{l}{Donation in Excess of \$200} & & \multicolumn{1}{l}{First \$200 of Donations} & & \multicolumn{1}{l}{Donations in Excess of \$200} \\
Federal & \multicolumn{1}{c}{17.0} & & \multicolumn{1}{c}{29.0} & & \multicolumn{1}{c}{15.0} & & \multicolumn{1}{c}{29.0} \\
\midrule
\multicolumn{1}{c}{Newfoundland and Labrador} & \multicolumn{1}{c}{11.73} & & \multicolumn{1}{c}{20.01} & & \multicolumn{1}{c}{7.7} & & \multicolumn{1}{c}{15.5} \\
Price Edward Island & \multicolumn{1}{c}{10.12} & & \multicolumn{1}{c}{17.26} & & \multicolumn{1}{c}{9.8} & & \multicolumn{1}{c}{16.7} \\
Nova Scotia & \multicolumn{1}{c}{9.95} & & \multicolumn{1}{c}{16.97} & & \multicolumn{1}{c}{8.79} & & \multicolumn{1}{c}{17.5} \\
New Brunswick & \multicolumn{1}{c}{10.71} & & \multicolumn{1}{c}{18.27} & & \multicolumn{1}{c}{9.65} & & \multicolumn{1}{c}{17.95} \\
Quebec2 & \multicolumn{1}{c}{23.0} & & \multicolumn{1}{c}{23.0} & & \multicolumn{1}{c}{20.0} & & \multicolumn{1}{c}{24.0} \\
Ontario & \multicolumn{1}{c}{8.16} & & \multicolumn{1}{c}{13.92} & & \multicolumn{1}{c}{6.05} & & \multicolumn{1}{c}{11.16} \\
Manitoba & \multicolumn{1}{c}{8.5} & & \multicolumn{1}{c}{14.5} & & \multicolumn{1}{c}{10.8} & & \multicolumn{1}{c}{17.4} \\
Saskatchewan & \multicolumn{1}{c}{9.4} & & \multicolumn{1}{c}{16.0} & & \multicolumn{1}{c}{11.0} & & \multicolumn{1}{c}{15.0} \\
Alberta & \multicolumn{1}{c}{7.74} & & \multicolumn{1}{c}{13.20} & & \multicolumn{1}{c}{10.0} & & \multicolumn{1}{c}{21.0} \\
British Columbia & \multicolumn{1}{c}{8.67} & & \multicolumn{1}{c}{14.79} & & \multicolumn{1}{c}{5.06} & & \multicolumn{1}{c}{14.7} \\
\midrule
\midrule
\multicolumn{8}{r}{1The credit rate is statutory rate, which is not subject to surtaxes. Surtaxes increase the value of the credit as they are calculated as a percentage of provincial/territorial income taxes net of the provincial/territorial Charitable Donation Tax Credit.} \\
\multicolumn{8}{l}{2 The tax credit rate for Quebec residents must be adjusted for the 16.5\% Quebec Abatement.} \\
\multicolumn{8}{l}{\textit{Source: Canada Revenue Agency; Department of Finance Canada calculations.}} \\
\end{tabular}%
\label{tab:addlabel}%
}
\end{table}
\end{document}
答案1
excel2latex 生成的标记过于复杂,根本\multicolumn{1}{c}
没有任何用处。这里我主要删除了添加的标记。从 excel 中获取纯文本逗号分隔值输出并添加所需的标记会更简单,但是
\documentclass[11pt]{article}
\usepackage{booktabs,siunitx}
\usepackage{graphicx}
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}
\centering
\footnotesize
\setlength\tabcolsep{5pt}
\caption{Charitable Donation Tax Credit Rates1, by Province, 1997 and 2009 (\%)}
\begin{tabular}{@{}l*{4}{S}@{}}
\toprule
& \multicolumn{2}{c}{1997} & \multicolumn{2}{c}{2009} \\
\cmidrule{2-3}\cmidrule{4-5}
& \multicolumn{1}{l}{First \$200} & \multicolumn{1}{l}{Excess of \$200} &
\multicolumn{1}{l}{First \$200} & \multicolumn{1}{l}{Excess of \$200} \\
Federal & 17.0 & 29.0 & 15.0 & 29.0 \\
\midrule
Newfoundland \& Labrador & 11.73 & 20.01 & 7.7 & 15.5 \\
Price Edward Island & 10.12 & 17.26 & 9.8 & 16.7 \\
Nova Scotia & 9.95 & 16.97 & 8.79 & 17.5 \\
New Brunswick & 10.71 & 18.27 & 9.65 & 17.95 \\
Quebec2 & 23.0 & 23.0 & 20.0 & 24.0 \\
Ontario & 8.16 & 13.92 & 6.05 & 11.16 \\
Manitoba & 8.5 & 14.5 & 10.8 & 17.4 \\
Saskatchewan & 9.4 & 16.0 & 11.0 & 15.0 \\
Alberta & 7.74 & 13.20 & 10.0 & 21.0 \\
British Columbia & 8.67 & 14.79 & 5.06 & 14.7 \\
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\begin{enumerate}
\item The credit rate is statutory rate, which is not subject to surtaxes. Surtaxes increase the value of the credit as they are calculated as a percentage of provincial/territorial income taxes net of the provincial/territorial Charitable Donation Tax Credit.
\item The tax credit rate for Quebec residents must be adjusted for the 16.5\% Quebec Abatement.
\end{enumerate}
\textit{Source: Canada Revenue Agency; Department of Finance Canada calculations.}
\end{table}
\end{document}
答案2
另一个。这个还考虑简化糟糕的标题设计(也许不是你想要的,但重点是要抓住一个想法,即带有许多行的标题并不令人愉悦)。事实上,这项工作最好是手头完成,从电子表格的原始复制和粘贴到 LaTeX 编辑器开始,或者导入 .csv 文件以调整不必要的复杂输出excel2latex
。
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs,siunitx,tabularx}
\newcolumntype{U}{S[table-format=4.3,round-mode=places, round-precision=2]}
\usepackage{graphicx}
\renewcommand\belowcaptionskip{1ex}
\begin{document}
% Table generated by hand 1.0 from MWE
\begin{table}
\caption{Charitable Donation Tax Credit Rates (\%)\protect\footnotemark[1], by Province.}
\label{tab:addlabel}%
\begin{tabularx}{\linewidth}{@{}XUUUU@{}}
\toprule
& \multicolumn{2}{c}{Donations in 1997} & \multicolumn{2}{c}{Donations in 2009} \\
\cmidrule(rl){2-3}\cmidrule(rl){4-5}
& \mbox{1st \$200} &
\mbox{$>\mathdollar200$} &
\mbox{1st \$200} &
\mbox{$>\mathdollar200$} \\
\midrule
Federal & 17.0 & 29.0 & 15.0 & 29.0 \\
Newfoundland and Labrador & 11.73 & 20.01 & 7.7 & 15.5 \\
Price Edward Island & 10.12 & 17.26 & 9.8 & 16.7 \\
Nova Scotia & 9.95 & 16.97 & 8.79 & 17.5 \\
New Brunswick & 10.71 & 18.27 & 9.65 & 17.95 \\
Quebec\footnotemark[2] & 23.0 & 23.0 & 20.0 & 24.0 \\
Ontario & 8.16 & 13.92 & 6.05 & 11.16 \\
Manitoba & 8.5 & 14.5 & 10.8 & 17.4 \\
Saskatchewan & 9.4 & 16.0 & 11.0 & 15.0 \\
Alberta & 7.74 & 13.20 & 10.0 & 21.0 \\
British Columbia & 8.67 & 14.79 & 5.06 & 14.7 \\\bottomrule
\end{tabularx}
\par\footnotesize\parskip1ex
\footnotemark[1] The credit rate is statutory rate, which is not subject to surtaxes. Surtaxes increase the value of the credit as they are calculated as a percentage of provincial/territorial income taxes net of the provincial/territorial Charitable Donation Tax.\par
\footnotemark[2] The tax credit rate for Quebec residents must be adjusted for the 16.5\% Quebec Abatement.\par
\emph{Source: Canada Revenue Agency; Department of Finance Canada calculations.}
\end{table}
\end{document}
答案3
使用threeparttable
和环境tablenotes
::tabular*
\documentclass[11pt]{article}
%\usepackage{geometry}
\usepackage[skip=1ex,
font=small,
labelfont=bf,
labelsep=newline,
singlelinecheck=false
]{caption}
\usepackage{booktabs, threeparttable}
\usepackage{siunitx}
%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[ht]
\begin{threeparttable}
\caption{Charitable Donation Tax Credit Rates\tnote{1}, by Province, 1997 and 2009 (\%)}
\label{tab:addlabel}
\setlength\tabcolsep{0pt}
\small
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}l SSSS}
\toprule
& \multicolumn{2}{c}{Donations in 1997}
& \multicolumn{2}{c}{Donations in 2009} \\
\cmidrule(lr){2-3}
\cmidrule(lr){4-5}
& {First \$200}
& {Excess of \$200}
& {First \$200}
& {Excess of \$200} \\
Federal & 17.0 & 29.0 & 15.0 & 29.0 \\
\midrule
Newfoundland and Labrador
& 11.73 & 20.01 & 7.7 & 15.5 \\
Price Edward Island
& 10.12 & 17.26 & 9.8 & 16.7 \\
Nova Scotia
& 9.95 & 16.97 & 8.79 & 17.5 \\
New Brunswick
& 10.71 & 18.27 & 9.65 & 17.95 \\
Quebec\tnote{2}
& 23.0 & 23.0 & 20.0 & 24.0 \\
Ontario & 8.16 & 13.92 & 6.05 & 11.16 \\
Manitoba & 8.5 & 14.5 & 10.8 & 17.4 \\
Saskatchewan
& 9.4 & 16.0 & 11.0 & 15.0 \\
Alberta & 7.74 & 13.20 & 10.0 & 21.0 \\
British Columbia
& 8.67 & 14.79 & 5.06 & 14.7 \\
\bottomrule
\end{tabular*}
\begin{tablenotes}\footnotesize
\item[1] The credit rate is statutory rate, which is not subject to surtaxes. Surtaxes increase the value of the credit as they are calculated as a percentage of provincial/territorial income taxes net of the provincial/territorial Charitable Donation Tax Credit.
\item[2] The tax credit rate for Quebec residents must be adjusted for the \SI{16.5}{\%} Quebec Abatement.
\smallskip
\item[] \textit{Source: Canada Revenue Agency; Department of Finance Canada calculations.}
\end{tablenotes}
\end{threeparttable}
\end{table}
答案4
这是一个包含、threeparttable
和的解决方案。我对其进行了一些重新设计;siunitx
colortbl
siunitx
\documentclass[11pt]{article}
\usepackage{booktabs,siunitx, makecell, caption}
\usepackage[flushleft]{threeparttable}
\usepackage[table, svgnames]{xcolor}
\usepackage[showframe, a4paper]{geometry}
\usepackage{graphicx}
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\captionsetup{labelsep = newline, labelfont = bf, font = small, singlelinecheck = off}
\begin{table}
\centering\setlength{\tabcolsep}{5pt}\setlength{\extrarowheight}{2pt}
\begin{threeparttable}
\small
\caption{Charitable Donation Tax Credit Rates1, by Province, 1997 and 2009 (\%)}
\rowcolors{4}{WhiteSmoke!70!Lavender}{white}
\begin{tabular}{@{}l*{3}{Sc}S}%
\toprule
\midrule
& \multicolumn{3}{c@{\quad}}{1997} & & \multicolumn{2}{r@{\quad}}{2009} \\
\cmidrule(lr){2-4}\cmidrule(lr){6-8} &{ \makecell{First \$\,200\\ of Donations}} & & {\makecell{Donation\\ in Excess\\ of \$\,200}} & & {\makecell{First \$\,200\\ of Donations}} & & {\makecell{Donations\\ in Excess\\ of \$\,200}} \\
\addlinespace
\rowcolor{Gainsboro!60!Lavender} Federal & 17.0 & & 29.0 & & 15.0 & & 29.0 \\
\addlinespace
Newfoundland and Labrador & 11.73 & & 20.01 & & 7.7 & & 15.5 \\
Price Edward Island & 10.12 & & 17.26 & & 9.8 & & 16.7 \\
Nova Scotia & 9.95 & & 16.97 & & 8.79 & & 17.5 \\
New Brunswick & 10.71 & & 18.27 & & 9.65 & & 17.95 \\
Quebec2 & 23.0 & & 23.0 & & 20.0 & & 24.0 \\
Ontario & 8.16 & & 13.92 & & 6.05 & & 11.16 \\
Manitoba & 8.5 & & 14.5 & & 10.8 & & 17.4 \\
Saskatchewan & 9.4 & & 16.0 & & 11.0 & & 15.0 \\
Alberta & 7.74 & & 13.20 & & 10.0 & & 21.0 \\
British Columbia & 8.67 & & 14.79 & & 5.06 & & 14.7 \\
\midrule
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\begin{tablenotes}
\item[1.]The credit rate is statutory rate, which is not subject to surtaxes. Surtaxes increase the value of the credit as they are calculated as a percentage of provincial/territorial income taxes net of the provincial/territorial Charitable Donation Tax Credit.
\item[2.]The credit rate is statutory rate, which is not subject to surtaxes. Surtaxes increase the value of the credit as they are calculated as a percentage of provincial/territorial income taxes net of the provincial/territorial Charitable Donation Tax Credit.\smallskip
\item[]\textit{Source: Canada Revenue Agency; Department of Finance Canada calculations.}
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}