2

I have created the following table, however the negative numbers are not aligned. Do you have any hacks on how I can solve this problem?

    \documentclass[paper=a4,pagesize,fontsize=11pt]{scrartcl}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{lmodern}
\geometry{a4paper,left=25mm,right=25mm, top=12mm, bottom=20mm}

    \begin{table}[htbp!]
    \caption{Koeffizienten der CFA}
    \setlength{\tabcolsep}{4.5pt}
    {\scriptsize
        \begin{tabular}{@{} lccccc @{} } \toprule
            & {B} & {SE} & {$z$} & {$p$} & {$\beta$} \\\midrule
            {Variablen}&&&&&\\ \midrule
            \emph{ Extraversion} &  &  & && \\      
            Item 1 & $ 1.000$&& && $0.72$\\
            Item 6 & $-0.64$&$0.04$& $-14.88$&$ < .001$& $-0.54$\\
            Item 11 & $ 1.15$&$0.06$& $18.94$& $< .001$ & $0.77$\\
            Item 16 & $ -0.80$&$0.05$& $-17.47$&$ < .001$& $-0.65$\\
            &&&&&\\
            \emph{ Verträglichkeit} &  &  & && \\
            Item 2 & $ 1.000$&& && $0.38$\\
            Item 7 & $-0.61$&$0.11$& $-5.56$&$ < .001$& $-0.23$\\
            Item 12 & $ 2.05$&$0.22$& $9.41$&$ < .001$& $0.73$\\
            Item 17 & $ 1.97$&$0.21$& $9.40$&$ < .001$& $0.73$\\
            &&&&&\\
            \emph{ Gewissenhaftigkeit} &  &  & && \\        
            Item 3 & $ 1.000$&& && $0.72$\\
            Item 8 & $-0.83$&$0.07$& $-12.45$&$ < .001$& $-0.48$\\
            Item 13 & $ 1.01$&$0.67$& $15.65$& $< .001$ & $0.70$\\
            Item 18 & $ 1.97$&$0.21$& $9.40$&$ < .001$& $0.73$\\
            &&&&&\\
            \emph{ Neurotizismus} &  &  & && \\     
            Item 4 & $ 1.000$&& && $0.63$\\
            Item 9 & $-0.72$&$0.06$& $-11.68$&$ < .001$& $-0.48$\\
            Item 14 & $ 1.03$&$0.07$& $13.93$& $< .001$ & $0.64$\\
            Item 19 & $ 1.00$&$0.07$& $14.05$&$ < .001$& $0.67$\\   
            &&&&&\\
            \emph{ Offenheit} &  &  & && \\     
            Item 5 & $ 1.000$&& && $0.40$\\
            Item 10 & $1.09$&$0.12$& $8.83$&$ < .001$& $0.40$\\
            Item 15 & $ 1.30$&$0.13$& $9.79$& $< .001$ & $0.48$\\
            Item 20 & $ 2.34$&$0.21$& $11.33$&$ < .001$& $0.81$\\   
            Item 21 & $ -2.35$&$0.21$& $-11.32$&$ < .001$& $-0.73$\\    
            \bottomrule  
        \end{tabular}
    }
\end{table}
  1. Also, do you know how I can make the table wider without changing the vertical spacing?

Right now, my table looks like this: Table right now

Thank you all very much for your help!

Kind regards, Milkovena

6
  • 1
    Take a look at the S type column from siunitx.
    – leandriis
    Mar 30, 2020 at 10:13
  • Why would you want to make your table wider than it currently is? Excessive white space will not improve the readability.
    – leandriis
    Mar 30, 2020 at 10:14
  • @leandriis that it not entirely true. Cramped data can benefit from more space. I agree that here is ot not really that relevant.
    – daleif
    Mar 30, 2020 at 10:17
  • Please complete your example into something compilable.
    – daleif
    Mar 30, 2020 at 10:18
  • @daleif: I totally agree, however I wouldn't necesarily describe the current table as to contain "cramped data".
    – leandriis
    Mar 30, 2020 at 10:18

1 Answer 1

2

Here are two versions of your table using siunitx to align the numbers in the table cells with respect to the decimal marker:

enter image description here

\documentclass[paper=a4,pagesize,fontsize=11pt]{scrartcl}
\usepackage{geometry}
%\usepackage[latin1]{inputenc}
%\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{siunitx}
\geometry{a4paper,left=25mm,right=25mm, top=12mm, bottom=20mm}

\begin{document}
    \begin{table}[htbp!]
    \caption{Koeffizienten der CFA}
\centering
        \begin{tabular}{@{} l
                            S[table-format=-1.4]
                            S[table-format=1.2]
                            S[table-format=-2.2]
                            S[table-format=<.4, add-integer-zero=false]
                            S[table-format=-1.2] @{} } \toprule
            & {B} & {SE} & { $z$ } & {$p$} & {$\beta$} \\\midrule
            {Variablen}&&&&&\\ \midrule
            \emph{ Extraversion} &  &  & && \\      
            Item 1 &   1.000 && &&  0.72 \\
            Item 6 &  -0.64 & 0.04 &  -14.88 &  < .001 & -0.54\\
            Item 11 &   1.15 & 0.06 &  18.94 &  < .001  & 0.77\\
            Item 16 &   -0.80 & 0.05 &  -17.47 &  < .001 & -0.65\\
            &&&&&\\
            \emph{ Verträglichkeit} &  &  & && \\
            Item 2 &   1.000 && &&  0.38 \\
            Item 7 &  -0.61 & 0.11 &  -5.56 &  < .001 &  -0.23 \\
            Item 12 &   2.05 & 0.22 &  9.41 &  < .001 &  0.73 \\
            Item 17 &   1.97 & 0.21 &  9.40 &  < .001 &  0.73 \\
            &&&&&\\
            \emph{ Gewissenhaftigkeit} &  &  & && \\        
            Item 3 &   1.000 && &&  0.72 \\
            Item 8 &  -0.83 & 0.07 &  -12.45 &  < .001 &  -0.48 \\
            Item 13 &   1.01 & 0.67 &  15.65 &  < .001  &  0.70 \\
            Item 18 &   1.97 & 0.21 &  9.40 &  < .001 &  0.73 \\
            &&&&&\\
            \emph{ Neurotizismus} &  &  & && \\     
            Item 4 &   1.000 && &&  0.63 \\
            Item 9 &  -0.72 & 0.06 &  -11.68 &  < .001 &  -0.48 \\
            Item 14 &   1.03 & 0.07 &  13.93 &  < .001  &  0.64 \\
            Item 19 &   1.00 & 0.07 &  14.05 &  < .001 &  0.67 \\   
            &&&&&\\
            \emph{ Offenheit} &  &  & && \\     
            Item 5 &   1.000 && &&  0.40 \\
            Item 10 &  1.09 & 0.12 &  8.83 &  < .001 &  0.40 \\
            Item 15 &   1.30 & 0.13 &  9.79 &  < .001  &  0.48 \\
            Item 20 &   2.34 & 0.21 &  11.33 &  < .001 &  0.81 \\   
            Item 21 &   -2.35 & 0.21 &  -11.32 &  < .001 &  -0.73 \\    
            \bottomrule  
        \end{tabular}
\end{table}



    \begin{table}[htbp!]
    \caption{Koeffizienten der CFA}
\centering
        \begin{tabular}{    l
                            S[table-format=-1.4]
                            S[table-format=1.2]
                            S[table-format=-2.2]
                            S[table-format=<.4, add-integer-zero=false]
                            S[table-format=-1.2] @{} } \toprule
            Variablen & {B} & {SE} & { $z$ } & {$p$} & {$\beta$} \\\midrule
            \multicolumn{6}{@{}l}{\emph{Extraversion}} \\      
            Item 1 &   1.000 && &&  0.72 \\
            Item 6 &  -0.64 & 0.04 &  -14.88 &  < .001 & -0.54\\
            Item 11 &   1.15 & 0.06 &  18.94 &  < .001  & 0.77\\
            Item 16 &   -0.80 & 0.05 &  -17.47 &  < .001 & -0.65\\
            \addlinespace
            \multicolumn{6}{@{}l}{\emph{Verträglichkeit}} \\
            Item 2 &   1.000 && &&  0.38 \\
            Item 7 &  -0.61 & 0.11 &  -5.56 &  < .001 &  -0.23 \\
            Item 12 &   2.05 & 0.22 &  9.41 &  < .001 &  0.73 \\
            Item 17 &   1.97 & 0.21 &  9.40 &  < .001 &  0.73 \\
            \addlinespace
            \multicolumn{6}{@{}l}{\emph{Gewissenhaftigkeit}} \\        
            Item 3 &   1.000 && &&  0.72 \\
            Item 8 &  -0.83 & 0.07 &  -12.45 &  < .001 &  -0.48 \\
            Item 13 &   1.01 & 0.67 &  15.65 &  < .001  &  0.70 \\
            Item 18 &   1.97 & 0.21 &  9.40 &  < .001 &  0.73 \\
            \addlinespace
            \multicolumn{6}{@{}l}{\emph{Neurotizismus}} \\     
            Item 4 &   1.000 && &&  0.63 \\
            Item 9 &  -0.72 & 0.06 &  -11.68 &  < .001 &  -0.48 \\
            Item 14 &   1.03 & 0.07 &  13.93 &  < .001  &  0.64 \\
            Item 19 &   1.00 & 0.07 &  14.05 &  < .001 &  0.67 \\   
            \addlinespace
            \multicolumn{6}{@{}l}{\emph{Offenheit}} \\     
            Item 5 &   1.000 && &&  0.40 \\
            Item 10 &  1.09 & 0.12 &  8.83 &  < .001 &  0.40 \\
            Item 15 &   1.30 & 0.13 &  9.79 &  < .001  &  0.48 \\
            Item 20 &   2.34 & 0.21 &  11.33 &  < .001 &  0.81 \\   
            Item 21 &   -2.35 & 0.21 &  -11.32 &  < .001 &  -0.73 \\    
            \bottomrule  
        \end{tabular}
\end{table}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.