3

I started to translate a table into German and building it in a LaTeX document following the APA guidelines (please ignore the missing label and caption or the missing Rho and other formatting stuff ;) ...):

\documentclass{article}
\usepackage{booktabs}
\usepackage{nicematrix}

\begin{document}

\begin{table} \begin{tabular}{lccccccccc} \toprule & \multicolumn{5}{c}{Durchschnitt} & \multicolumn{2}{c}{80% GI} & \multicolumn{2}{c}{95% KI} \ \cmidrule(lr){2-6}\cmidrule(lr){7-8}\cmidrule(lr){9-10} Merkmal & k & N & r & p & SD & UG & OG & UG & OG \ \cmidrule{1-10} Neurotizismus & 48 & 8,025 & --.17 & --.24 & .18 & --.47 & --.01 & --.30 & --.18 \ Extraversion & 60 & 11,705 & .22 & .31 & .17 & .09 & .53 & .26 & .36 \ Offenheit & 37 & 7,221 & .16 & .24 & .11 & .09 & .38 & .19 & .28 \ Verträglichkeit & 42 & 9,801 & .06 & .08 & .17 & --.14 & .29 & .02 & .13 \ Gewissenhaftigkeit & 35 & 7,510 & .20 & .28 & .17 & .06 &.51 & .22 & .34 \ \bottomrule \end{tabular} \end{table}

\end{document}

What's missing is the annotation I'd like to add underneath the table, that shall have only the width of the table itself like in the original table ("Note"):

enter image description here

Does anyone have ideas how to include such an annotation?

Thanks in advance, appreciate your support! Florian

  • You could use the tabularray package, that allows notes and remarks to be inserted. – alchemist Apr 01 '23 at 01:40
  • 2
    Alternatively, you could take a look at the tablenotes environment provided by the threeparttable package. See for example: https://tex.stackexchange.com/a/20007/134144 – leandriis Apr 01 '23 at 09:15
  • 1
    Off-topic: IMNSHO, it's dubious practice to employ -- (en-dash) when what is really needed is a math-mode - (minus) symbol. For the font that's used in your screenshot, the two symbols happen to look reasonably similar. However, that's not the case with all fonts. – Mico Apr 02 '23 at 11:25
  • Thanks Mico, you're absolutely right ... ;) – Florian Blaschke Apr 02 '23 at 12:02

3 Answers3

2

It turned out you have all the components to achieve what you're asking already available in the nicematrix package. According to section 13.3 of the manual you can enter and adapt tabular notes in a NiceTabular environment. To use that option you need to load the enumitem package too.

So this slight adaptation of your code gives the desired output:

\documentclass[11pt]{article}

\usepackage{booktabs} \usepackage{nicematrix} \usepackage{enumitem} % <- needed by nicematrix to include tabular notes

\begin{document}

\begin{table}
    \NiceMatrixOptions{caption-above}
    \begin{NiceTabular}
        [caption = Big Five Persönlichkeitsmerkmale und Führung\tabularnote{aus dem Englischen übersetzt },
        tabularnote = \textit{Notiz:} Wir haben die Formel von Whitener's (1990) für den Standardfehler der mittleren Korrelation bei der Berechnung von Konfidenzintervallen verwendet ]
        {lccccccccc}
        \toprule
        &amp; \multicolumn{5}{c}{Durchschnitt} &amp; \multicolumn{2}{c}{80\% GI} &amp; \multicolumn{2}{c}{95\% KI} \\
        \cmidrule(lr){2-6}\cmidrule(lr){7-8}\cmidrule(lr){9-10}
        Merkmal &amp; k &amp; N &amp; r &amp; $\rho$\tabularnote{$\rho$ = geschätzte korrigierte Schätzung} &amp; SD &amp; UG &amp; OG &amp; UG &amp; OG \\
        \cmidrule{1-10}
        Neurotizismus &amp; 48 &amp; 8,025 &amp; --.17 &amp; --.24 &amp; .18 &amp; --.47 &amp; --.01 &amp; --.30 &amp; --.18 \\
        Extraversion &amp; 60 &amp; 11,705 &amp; .22 &amp; .31 &amp; .17 &amp; .09 &amp; .53 &amp; .26 &amp; .36 \\
        Offenheit &amp; 37 &amp; 7,221 &amp; .16 &amp; .24 &amp; .11 &amp; .09 &amp; .38 &amp; .19 &amp; .28 \\
        Verträglichkeit &amp; 42 &amp; 9,801 &amp; .06 &amp; .08 &amp; .17 &amp; --.14 &amp; .29 &amp; .02 &amp; .13 \\
        Gewissenhaftigkeit &amp; 35 &amp; 7,510 &amp; .20 &amp; .28 &amp; .17 &amp; .06 &amp;.51 &amp; .22 &amp; .34 \\
        \bottomrule
    \end{NiceTabular}
\end{table}

\end{document}

nicematrix with notes

alchemist
  • 1,761
  • That's perfect, thanks a lot! There also is a way to achieve the annotation with the tablenotes environment provided by the threeparttable as mentioned by @leandriis, so now I have two solutions. Thanks a lot! – Florian Blaschke Apr 01 '23 at 10:12
  • 1
    tabularray does the same thing. You could also use the ctan package, but in my experience that doesn't do well with LuaLaTeX. – alchemist Apr 01 '23 at 10:54
2

Edit:
Corrected is writing of decimal numbers formation (removed zeros from decimal numbers)

By use of the tabularray packages with libraries booktabs and siunitx˛ code is simple, MWE need only pone compilation for final result, numbers are aligned at decimal points:

\documentclass[11pt]{article}
\usepackage{geometry}   % for formatting page layout
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\sisetup{group-separator={,},
         input-decimal-markers={.},
         parse-numbers=false}

\begin{document}

\begin{table}

\begin{talltblr}[ caption = {Big Five Persönlichkeitsmerkmale und Führung\TblrNote{a}}, remark{Notiz} = {Wir haben die Formel von Whitener's (1990) für den Standardfehler der mittleren Korrelation bei der Berechnung von Konfidenzintervallen verwendet}, note{a} = {aus dem Englischen übersetzt}, note{b} = {$\rho$ = geschätzte korrigierte Schätzung} ]{colspec = {l c Q[c, si={table-format= 2.3}] *{7}{Q[c, si={table-format=-1.2}]} }, row{1,2} = {guard} } \toprule & \SetCell[c=5]{c} Durchschnitt & & & & & \SetCell[c=2]{c} \qty{80}{%} GI & & \SetCell[c=2]{c} \qty{80}{%} KI & \ \cmidrule[lr]{2-6} \cmidrule[lr]{7-8} \cmidrule[lr]{9-10} Merkmal & k & N & r & $\rho$ & SD & UG & OG & UG & OG \ \midrule Neurotizismus & 48 & 8,025 & -.17 & -.24 & .18 & -.47 & -.01 & -.30 & -.18 \ Extraversion & 60 & 11,705 & .22 & .31 & .17 & .09 & .53 & .26 & .36 \ Offenheit & 37 & 7,221 & .16 & .24 & .11 & .09 & .38 & .19 & .28 \ Verträglichkeit & 42 & 9,801 & .06 & .08 & .17 & -.14 & .29 & .02 & .13 \ Gewissenhaftigkeit & 35 & 7,510 & .20 & .28 & .17 & .06 & .51 & .22 & .34 \ \bottomrule \end{talltblr} \end{table} \end{document}

enter image description here

Addendum:
In the case, when is important that remark (Notes:) is before notes (1, b), than you need to define new theme for talltblr:

\DefTblrTemplate{lastfoot}{mytheme}%
{
\UseTblrTemplate{remark}{default}
\UseTblrTemplate{note}{default}
}
\NewTblrTheme{mytheme}%
{
\SetTblrTemplate{lastfoot}{mytheme}
}

which should be inserted before table or in preamble (for global settings) and change talltblr preamble to:

\begin{talltblr}[theme=mytheme,
caption = {Big Five Persönlichkeitsmerkmale und Führung\TblrNote{a}},
remark{Notiz} = {Wir haben die Formel von Whitener's (1990) für den
                Standardfehler der mittleren Korrelation bei der Berechnung von Konfidenzintervallen verwendet},
     note{a} = {aus dem Englischen übersetzt},
     note{b} = {$\rho$ = geschätzte korrigierte Schätzung}
                ]{colspec = {l c  Q[c, si={table-format= 5.0}]
                             *{7}{Q[c, si={table-format=-1.2}]}
                            },
                  row{1,2} = {guard}
                 }

enter image description here

Zarko
  • 296,517
1

Here's a solution that encases the tabular material and the legend in a threeparttable enviroment. That's all it takes to assure that the width of the legend is the same as that of the tabular material.

I would also make an effort to align the numbers in the 9 data columns on their (implicit or explicit) decimal markers. In the table shown below, this is achieved by employing the S column type that's provided by the siunitx package.

enter image description here

\documentclass{article}
\usepackage{booktabs}
%% new:
\usepackage{siunitx} % for 'S' column type
\usepackage[flushleft]{threeparttable} % for 'threeparttable' env.
\usepackage{lipsum} % for filler text

\begin{document}

\begin{table} \sisetup{group-separator={,},group-minimum-digits=4} \centering \setlength\tabcolsep{0pt} % let LaTeX figure out width of intercolumn spaces

\begin{threeparttable} % (proviede a suitable \caption statement)

\begin{tabular}{0.95\textwidth}% % <-- set desired target width {@{\extracolsep{\fill}} l S[table-format= 2.0] S[table-format= 5.0] {2}{S[table-format=-1.2]} S[table-format= 1.2] *{4}{S[table-format=-1.2]} }

\toprule Merkmal & \multicolumn{5}{c}{Durchschnitt} & \multicolumn{2}{c}{80% GI} & \multicolumn{2}{c}{95% KI} \ \cmidrule{2-6} \cmidrule{7-8} \cmidrule{9-10} & {$k$} & {$N$} & {$r$} & {$\rho$} & {SD$_{\rho}$} & {UG} & {OG} & {UG} & {OG} \ \midrule Neurotizismus & 48 & 8025 & -.17 & -.24 & .18 & -.47 & -.01 & -.30 & -.18 \ Extraversion & 60 & 11705 & .22 & .31 & .17 & .09 & .53 & .26 & .36 \ Offenheit & 37 & 7221 & .16 & .24 & .11 & .09 & .38 & .19 & .28 \ Verträglichkeit & 42 & 9801 & .06 & .08 & .17 & -.14 & .29 & .02 & .13 \ Gewissenhaftigkeit & 35 & 7510 & .20 & .28 & .17 & .06 & .51 & .22 & .34 \ \bottomrule \end{tabular*}

\medskip \footnotesize \lipsum[2][1-5] % <-- replace with text of legend.

\end{threeparttable} \end{table}

\end{document}

Mico
  • 506,678