1
\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}

I am pretty new to latex and can't get this multicolumn to work. I basically need this link at the bottom to span over several rows, but i couldn't make it work with the command multirow.

4
  • Make the multicolumn a p column instead of l. You have 16cm + 6\tabcolsep to play with. BTW, you can move \arrayrulewidth=0,25mm outside the tabular but inside the table. You can move global changes to the preamble. Also, table (normally) does not have a required argument, so the "Ernstmalig ..." is simply treated as a line of text. Commented Jan 20 at 15:12
  • 1
    Also, you should use \url (url package) to handle the odd characters in the url. Commented Jan 20 at 15:16
  • Welcome. // Please add the missing lines at the beginning, so your code will compile once we copied it. Thank you.
    – MS-SPO
    Commented Jan 20 at 18:21
  • Don't scale tables using \resizebox (or \scalebox). This is always poor typesetting. And don't limit the float options to h. Despite LaTeX does always use ht, if h does not work, I would always recommend to also allow p. And if a table really must not float, you should not use a float. And please, next time don't show a code snippet, but a minimal working example starting with \documentclass and ending with \end{document} and with all packages loaded that are needed for the LaTeX run.
    – cabohah
    Commented Jan 21 at 10:25

3 Answers 3

4

With the package xurl you don't have to worry about url hypenation (see here).

I also used threparttable for the table notes and an ordinary tblr (just to give you another alternative w.r.t. NonnoDino's one from which I started).

\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}

enter image description here

However, if you are writing an official document and nobody obliged you to use that style, it should be better to use a professional table, like this:

\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}

enter image description here

2
  • Thanks for your nice inputs, I will try them all out. The three part table as you use, looks so much simpier! Just one question, what are the curly braces in the toprule for?
    – Lukas E.
    Commented Jan 23 at 16:06
  • @LukasE. If you put the text into curly braces, siunitx does not consider it. Thank you for accepting my answer.
    – CarLaTeX
    Commented Jan 23 at 16:41
1

I suggest using the url package, which provides the \url command specifically designed for typesetting URLs. I've also utilized \parbox to create a paragraph, allowing me to write the URL on multiple lines. Here is your modified code:

\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}

original

However, I do think that this is poorly typeset. I would suggest using the tabularray package, which offers many options such as the ability to set specific colors for ranges of cells, columns, or rows (even the option to specify for even and odd). tabularray also supports notes below tables. Here is the code for creating the table with the tabularray package:

\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}

enter image description here

Note: Both the siunitx and booktabs packages can be used in a simple tabular environment. The first provides the option to perfectly typeset numbers (in this example, you can see that all the numbers have been aligned vertically by the dot), and the second one provides better spacing between rows and horizontal rules specifically designed for tables, such as \toprule, \midrule, and \bottomrule.

1
  • 1
    You've also appropriately removed the \resizebox. booktabs would argue that you should still remove the vertical rules and the shading.
    – Teepeemm
    Commented Jan 21 at 1:17
1

You don't need that the source is inside the tabular.

With the code below I avoid \resizebox (never use it for tables). Only a few computations are necessary and, a posteriori, a small trick in order for the Phosphor column header to fit.

Using siunitx is recommended.

\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}

enter image description here

Note that the standard classes are set up for captions below the table; there must be vertical space between them.

What you put in braces after \begin{table}[h] is a bit mysterious. In any case, just [h] is an error.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .