\begin{document}
\begin{table}[h]{Erstmalig im Inland in Verkehr gebrachte Düngemittel}
\caption{Düngemittel Reinnährstoffabsatz von 1995/96 bis 2013/14 (Menge in t)}
\resizebox{\textwidth}{!}{\begin{tabular}{|p{4cm}|p{4cm}p{4cm}p{4cm}|}
\noalign{\global\arrayrulewidth=0,25mm}
\hline \rowcolor{brown!80}
Jahr & Stickstoff (N) & Phosphor (\ce{P2O5}) & Kalium (\ce{K2O}) \\
\hline \rowcolor{brown!20}
2013/14 & 111.615 & 32.731 & 32.559 \\
2011/12 & 97.721 & 26.198 & 32.478 \\
\rowcolor{brown!20}
2009/10 & 90.639 & 22.121 & 23.356 \\
2007/08 & 134.382 & 44.704 & 49.787 \\
\rowcolor{brown!20}
2005/06 & 103.692 & 34.979 & 40.738 \\
2003/04 & 100.789 & 39.357 & 49.532 \\
\rowcolor{brown!20}
2001/02 & 127.585 & 47.138 & 50.099 \\
1999/00 & 121.644 & 48.548 & 55.241 \\
\rowcolor{brown!20}
1997/98 & 127.537 & 57.264 & 61.537 \\
1995/96 & 125.309 & 52.272 & 59.755 \\
\hline
\multicolumn{4}{l}{Quelle: https://www.ama.at/getattachment/f3f479f8-6bc9-42e3-be83-d8fd4112a937/281\_Dungemittel\_Reinnahrstoffabsatz-ab-1995.pdf (besucht am 20-01-2024)}
\end{tabular}}
\end{table}
\end{document}
我对 Latex 还很陌生,无法让这个多列功能正常工作。我基本上需要底部的这个链接跨越几行,但我无法使用命令 multirow 使其工作。
答案1
随附包装xurl
您不必担心 URL 连字符(请参阅这里)。
我也使用了threparttable
表格注释和普通注释tblr
(只是为了给你提供另一个替代方案,相对于我开始使用的 NonnoDino 注释)。
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage[ngerman]{babel}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\NewColumnType{V}[1]{X[m,c,si={table-format=#1}]}
\sisetup{table-number-alignment=center, exponent-product=\cdot}
\usepackage[para]{threeparttable}
\usepackage[version=3]{mhchem}
\usepackage{caption}
\usepackage{xurl}
\begin{document}
\begin{table}[h]
\caption{Düngemittel Reinnährstoffabsatz von 1995/96 bis 2013/14 (Menge in t)}
\begin{threeparttable}
\begin{tblr}{colspec={|X[m,c]|V{3.3}V{2.3}V{2.3}|},
row{even} = {brown!20}, row{1} = {brown!80}
}
\toprule
Jahr & {{{Stickstoff (N)}}} & {{{Phosphor (\ce{P2O5})}}} & {{{Kalium (\ce{K2O})}}} \\
\midrule
2013/14 & 111.615 & 32.731 & 32.559 \\
2011/12 & 97.721 & 26.198 & 32.478 \\
2009/10 & 90.639 & 22.121 & 23.356 \\
2007/08 & 134.382 & 44.704 & 49.787 \\
2005/06 & 103.692 & 34.979 & 40.738 \\
2003/04 & 100.789 & 39.357 & 49.532 \\
2001/02 & 127.585 & 47.138 & 50.099 \\
1999/00 & 121.644 & 48.548 & 55.241 \\
1997/98 & 127.537 & 57.264 & 61.537 \\
1995/96 & 125.309 & 52.272 & 59.755 \\
\bottomrule
\end{tblr}
\begin{tablenotes}
Quelle = \url{https://www.ama.at/getattachment/f3f479f8-6bc9-42e3-be83-d8fd4112a937/281_Dungemittel_Reinnahrstoffabsatz-ab-1995.pdf} (besucht am 20-01-2024)
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
但是,如果你正在编写正式文件并且没有人强制你使用这种风格,那么最好使用专业的表格,如下所示:
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage[ngerman]{babel}
\usepackage{xcolor}
\usepackage{siunitx}
\sisetup{table-number-alignment=center, exponent-product=\cdot}
\usepackage{booktabs}
\newcolumntype{V}[1]{S[table-format =#1]}
\renewcommand{\arraystretch}{1.2}
\usepackage[para]{threeparttable}
\usepackage[version=3]{mhchem}
\usepackage{caption}
\usepackage{xurl}
\begin{document}
\begin{table}[h]\centering
\caption{Düngemittel Reinnährstoffabsatz von 1995/96 bis 2013/14 (Menge in t)}
\begin{threeparttable}
\begin{tabular}{cV{3.3}V{2.3}V{2.3}}
\toprule
Jahr & {Stickstoff (N)} & {Phosphor (\ce{P2O5})} & {Kalium (\ce{K2O})} \\
\midrule
2013/14 & 111.615 & 32.731 & 32.559 \\
2011/12 & 97.721 & 26.198 & 32.478 \\
2009/10 & 90.639 & 22.121 & 23.356 \\
2007/08 & 134.382 & 44.704 & 49.787 \\
2005/06 & 103.692 & 34.979 & 40.738 \\
2003/04 & 100.789 & 39.357 & 49.532 \\
2001/02 & 127.585 & 47.138 & 50.099 \\
1999/00 & 121.644 & 48.548 & 55.241 \\
1997/98 & 127.537 & 57.264 & 61.537 \\
1995/96 & 125.309 & 52.272 & 59.755 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
Quelle = \url{https://www.ama.at/getattachment/f3f479f8-6bc9-42e3-be83-d8fd4112a937/281_Dungemittel_Reinnahrstoffabsatz-ab-1995.pdf} (besucht am 20-01-2024)
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案2
我建议使用url
包,它提供了\url
专门为排版 URL 而设计的命令。我还用它\parbox
来创建一个段落,这样我就可以在多行上写 URL。这是您修改后的代码:
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage[ngerman]{babel}
\usepackage[table]{xcolor}
\usepackage[version=3]{mhchem}
\usepackage{url} % <--- I have added this package here
\begin{document}
\begin{table}[h]
\caption{Düngemittel Reinnährstoffabsatz von 1995/96 bis 2013/14 (Menge in t)}
\resizebox{\textwidth}{!}{\begin{tabular}{|p{4cm}|p{4cm}p{4cm}p{4cm}|}
\noalign{\global\arrayrulewidth=0,25mm}
\hline \rowcolor{brown!80}
Jahr & Stickstoff (N) & Phosphor (\ce{P2O5}) & Kalium (\ce{K2O}) \\
\hline \rowcolor{brown!20}
2013/14 & 111.615 & 32.731 & 32.559 \\
2011/12 & 97.721 & 26.198 & 32.478 \\
\rowcolor{brown!20}
2009/10 & 90.639 & 22.121 & 23.356 \\
2007/08 & 134.382 & 44.704 & 49.787 \\
\rowcolor{brown!20}
2005/06 & 103.692 & 34.979 & 40.738 \\
2003/04 & 100.789 & 39.357 & 49.532 \\
\rowcolor{brown!20}
2001/02 & 127.585 & 47.138 & 50.099 \\
1999/00 & 121.644 & 48.548 & 55.241 \\
\rowcolor{brown!20}
1997/98 & 127.537 & 57.264 & 61.537 \\
1995/96 & 125.309 & 52.272 & 59.755 \\
\hline
% I have modified the line below ⬇
\multicolumn{4}{l}{\parbox{\linewidth}{Quelle: \url{https://www.ama.at/getattachment/f3f479f8-6bc9-42e3-be83-d8fd4112a937/281_Dungemittel_Reinnahrstoffabsatz-ab-1995.pdf} (besucht am 20-01-2024)}}
\end{tabular}}
\end{table}
\end{document}
不过,我确实认为这排版很差。我建议使用tabularray
包,它提供许多选项,例如能够为单元格、列或行的范围设置特定颜色(甚至可以指定偶数和奇数)。tabularray
还支持表格下方的注释。以下是使用该包创建表格的代码tabularray
:
\documentclass[a4paper]{article}
\usepackage[margin=1in]{geometry}
\usepackage[ngerman]{babel}
\usepackage{booktabs}
\PassOptionsToPackage{table}{xcolor}
\usepackage[table]{xcolor}
\usepackage{siunitx}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\usepackage[version=3]{mhchem}
\usepackage{booktabs}
\usepackage{tabularray}
\usepackage{siunitx}
\NewColumnType{V}[1]{X[m,c,si={table-format=#1}]}
\sisetup{table-number-alignment=center, exponent-product=\cdot}
\PassOptionsToPackage{hyphens}{url}
\usepackage{url}
\begin{document}
\begin{table}[h]
\begin{longtblr}[caption={Düngemittel Reinnährstoffabsatz von 1995/96 bis 2013/14 (Menge in t)},
remark{Quelle} = {\quad\parbox{0.85\linewidth}{\url{https://www.ama.at/getattachment/f3f479f8-6bc9-42e3-be83-d8fd4112a937/281_Dungemittel_Reinnahrstoffabsatz-ab-1995.pdf}\\(besucht am 20-01-2024)}}]{colspec={|X[m,c]|V{3.3}V{2.3}V{2.3}|},
row{even} = {brown!20}, row{1} = {brown!80}
}
\toprule
Jahr & {{{Stickstoff (N)}}} & {{{Phosphor (\ce{P2O5})}}} & {{{Kalium (\ce{K2O})}}} \\
\midrule
2013/14 & 111.615 & 32.731 & 32.559 \\
2011/12 & 97.721 & 26.198 & 32.478 \\
2009/10 & 90.639 & 22.121 & 23.356 \\
2007/08 & 134.382 & 44.704 & 49.787 \\
2005/06 & 103.692 & 34.979 & 40.738 \\
2003/04 & 100.789 & 39.357 & 49.532 \\
2001/02 & 127.585 & 47.138 & 50.099 \\
1999/00 & 121.644 & 48.548 & 55.241 \\
1997/98 & 127.537 & 57.264 & 61.537 \\
1995/96 & 125.309 & 52.272 & 59.755 \\
\bottomrule
\end{longtblr}
\end{table}
\end{document}
注意:siunitx
和booktabs
包可以在简单的表格环境中使用。第一个包提供了完美排版数字的选项(在此示例中,您可以看到所有数字都已按点垂直对齐),第二个包提供了更好的行间距和专为表格设计的水平规则,例如\toprule
、\midrule
和\bottomrule
。
答案3
您不需要将源放在表格内。
使用下面的代码我避免\resizebox
(绝不将其用于表格)。只需要进行少量计算,并且事后进行一个小技巧,就可以使 Phosphor 列标题适合。
siunitx
建议使用。
\documentclass[draft]{article}
\usepackage{siunitx}
\usepackage[table]{xcolor}
\usepackage[version=4]{mhchem}
\usepackage{xurl}
\usepackage{caption}
\newlength{\colwidth}
\begin{document}
\begin{table}[htp]
%% {Erstmalig im Inland in Verkehr gebrachte Düngemittel}
\caption{Düngemittel Reinnährstoffabsatz von 1995/96 bis 2013/14 (Menge in~t)}
\setlength{\arrayrulewidth}{0.25mm}
\setlength{\colwidth}{\dimeval{(\textwidth-3\arrayrulewidth-8\tabcolsep)/4}}
\begin{tabular}{
|w{l}{\colwidth-0pt}|
S[table-format=3.3,table-column-width=\colwidth]
S[table-format=2.3,table-column-width=\colwidth]
S[table-format=2.3,table-column-width=\colwidth]
|
}
\hline \rowcolor{brown!80}
Jahr & {Stickstoff (\ce{N})} & {\makebox[0pt]{Phosphor (\ce{P2O5})}} & {Kalium (\ce{K2O})} \\
\hline \rowcolor{brown!20}
2013/14 & 111.615 & 32.731 & 32.559 \\
2011/12 & 97.721 & 26.198 & 32.478 \\
\rowcolor{brown!20}
2009/10 & 90.639 & 22.121 & 23.356 \\
2007/08 & 134.382 & 44.704 & 49.787 \\
\rowcolor{brown!20}
2005/06 & 103.692 & 34.979 & 40.738 \\
2003/04 & 100.789 & 39.357 & 49.532 \\
\rowcolor{brown!20}
2001/02 & 127.585 & 47.138 & 50.099 \\
1999/00 & 121.644 & 48.548 & 55.241 \\
\rowcolor{brown!20}
1997/98 & 127.537 & 57.264 & 61.537 \\
1995/96 & 125.309 & 52.272 & 59.755 \\
\hline
\end{tabular}
\smallskip
\parbox[t]{\textwidth}{%
Quelle: \url{https://www.ama.at/getattachment/f3f479f8-6bc9-42e3-be83-d8fd4112a937/281\_Dungemittel\_Reinnahrstoffabsatz-ab-1995.pdf} (besucht am 20-01-2024)%
}
\end{table}
\end{document}
请注意,标准类别是为表格下方的标题设置的;必须它们之间有垂直空间。
括号后面的内容\begin{table}[h]
有点神秘。无论如何,这只是[h]
一个错误。