4

I know I have asked this question before but I would be really grateful if someone could explain stepwise to me how to solve the problem (instead of just posting the changed code, which I also found really really nice and helpful but I did not learn how to come to the solution on my own). The problem is probably fairly easy to solve for most of you. I have a table and I would like to have the positive and negative numbers aligned.

 \documentclass[paper=a4, pagesize, fontsize=11pt]{scrartcl} %Doku: "scrguide"
 \usepackage{pdfpages}
 \usepackage[latin1]{inputenc}  % Eingabekodierung
 \usepackage[T1]{fontenc}       % Fontkodierung
 \usepackage[ngerman]{babel}    % deutsche Sprachenunterstützung; Doku: "gerdoc"
% \usepackage[english]{babel}    % Bei Bedarf: englische Sprachenunterstützung
 \usepackage{lmodern}           % Schrift: Latin Modern
 \usepackage{microtype}         % mikrotypographische Erweiterungen von pdfTeX; s.a. microtype-DE
 \usepackage{amsmath}           % AMSmath-Paket der American Mathematical Society (AMS)
 \usepackage{color}             % Verwendung von Farben 
 \usepackage{graphicx}          % Einbinden von Grafiken; Doku: "grfguide"
 \usepackage{hyperref}          % Querverweise & Links anklickbar
 \usepackage{apacite}           % Zitierregeln nach APA
 \usepackage{csquotes}          % Anführungszeichen mit \enquote{...}
\usepackage{enumerate}
 \definecolor{indigo}{rgb}{0.0, 0.25, 0.42}
 \definecolor{officegreen}{rgb}{0.0, 0.5, 0.0}
 \definecolor{azure}{rgb}{0.0, 0.5, 1.0}
 \usepackage{float}
% --- Behübschungen
 \setkomafont{captionlabel}{\small\sffamily\bfseries} % kleinere Beschriftungen
 \addtokomafont{caption}{\small}                      % --''--
 \renewcommand{\baselinestretch}{1.3}  % Zeilenabstand im Text
 \renewcommand{\arraystretch}{1}     % Zeilenabstand in mehrzeiligen Formeln und Tabellen
 \setlength{\parskip}{1.3ex}           % = space between paragraphs in height of "x"
 \setlength{\parindent}{0pt}           % 0 pt  = indentation
 \hypersetup{                          % Gestaltung interner Links [hyperref]:
   pdfborder={0 0 0},                                           % keine Rahmen um Links
   colorlinks=true,linkcolor=azure,urlcolor=red,citecolor=blue % Links färbig hervorheben
%   colorlinks=false  % Links nicht färbig hervorheben
} % end of hypersetup`

\usepackage{geometry} \usepackage{caption} \usepackage{longtable}

%\usepackage{threeparttablex} \usepackage{makecell}

\begin{document}

\begin{table}[H]

\caption{Ergebnisse der Schätzung über Personenparameter} \label{tab:personen}

\scriptsize \begin{tabular}{p{2cm}cSSccccccc} &\multicolumn{2}{c}{Extraversion}& \multicolumn{2}{c}{Neurotizismus} &\multicolumn{2}{c}{Offenheit} &\multicolumn{2}{c}{Verträglichkeit} & \multicolumn{2}{c}{Gewissenhaftigkeit} \ \cmidrule(l){2-3} \cmidrule(l){4-5} \cmidrule(l){6-7} \cmidrule(l){8-9} \cmidrule(l){10-11} &{EAP}&{WLE}&{EAP}&{WLE}&{EAP}&{WLE}&{EAP}&{WLE}&{EAP}&{WLE}\ \toprule Person 1&{0.74}&{0.79}&{-0.46}&{-0.53}& {1.08} &{1.69}& {0.39}& {0.58} &{0.83}&{1.08} \ Person 2&{-1.68}&{-2.07} &{0.33}&{0.40}&{-0.37}&{-0.53}&{0.10}& {0.14} &{-0.31}&{-0.50}\ Person 3&{1.99}&{3.28}&{-0.25}&{-0.28}& {-1.12}&{-1.38}&{-0.04}& {-0.07} &{1.20}&{1.80}\ Person 4&{0.74}&{0.79}&{0.72}&{0.91}&{0.81}&{1.08}&{-0.04}& {-0.07} &{-0.31}&{-0.50}\ Person 5&{-0.12}&{-0.21} &{-0.06}&{-0.05}&{0.15}&{0.07}& {0.39}& {0.58}&{0.83}&{1.08}\ Person 6 &{0.43}&{0.40} &{0.72}&{0.91}& {1.38}&{2.90}&{0.10}& {0.14} &{-0.06}&{-0.20}\ Person 7&{1.99}&{3.28} &{-0.90}&{-1.18}&{0.57}&{0.65}&{0.70}& {1.16} &{0.83}&{1.08}\ Person 8 &{-1.13}&{-1.32}&{-0.46}&{-0.53}&{0.15}&{0.07}&{0.54}& {0.84}&{0.21}&{0.14}\ Person 9 &{-1.40}&{-1.66}&{1.68}&{2.89}&{1.08}&{1.69}&{-0.33}& {-0.50} &{0.83}&{1.08}\ Person 10&{-0.62}&{-0.74}&{0.33}&{0.40}&{-1.27}&{-1.56}&{-0.78}& {-1.34} &{-0.77}&{-1.01}\ \bottomrule

\end{tabular}

\begin{tablenotes} \item Hinweis. In der Tabelle sind lediglich die Parameter für die ersten zehn Personen dargestellt. \end{tablenotes} \end{table}

\end{document}

I have tried it with the column definition S but it still does not work.

Would anyone of you be so kind and help me out with this one? I am also very interested in what each of your suggested changes exactly does to the table so that I am able to change the problem on my own in the future.

Thank you very much :=)

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
Milkovena
  • 121

1 Answers1

6

First of all, the numbers should not be braced. Also the correct specification for the columns should be used, in this case

S[table-format=-1.2]

meaning “minus sign”, “one-digit integral part”, “two-digit fractional part”.

With tabular* and setting \tabcolsep to zero, we leave to TeX to compute the intercolumn space. It turns out that the table doesn't require to reduce the font size, provided the too wide column headers are abbreviated.

\documentclass[paper=a4, pagesize, fontsize=11pt]{scrartcl} %Doku: "scrguide"

\usepackage{siunitx,booktabs}

\begin{document}

\begin{table}[htp] \centering \caption{Ergebnisse der Schätzung über Personenparameter} \label{tab:personen}

%\footnotesize

\setlength{\tabcolsep}{0pt} \begin{tabular}{\textwidth}{ @{\extracolsep{\fill}}% fill the space between columns l % one left aligned column {10}{S[table-format=-1.2]} % ten columns with numbers } \toprule &\multicolumn{2}{c}{E} &\multicolumn{2}{c}{N} &\multicolumn{2}{c}{O} &\multicolumn{2}{c}{V} &\multicolumn{2}{c}{G} \ \cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9} \cmidrule{10-11} &{EAP}&{WLE}&{EAP}&{WLE}&{EAP}&{WLE}&{EAP}&{WLE}&{EAP}&{WLE} \ \midrule Person 1 & 0.74 & 0.79 & -0.46 & -0.53 & 1.08 & 1.69 & 0.39 & 0.58 & 0.83 & 1.08 \ Person 2 & -1.68 & -2.07 & 0.33 & 0.40 & -0.37 & -0.53 & 0.10 & 0.14 & -0.31 & -0.50 \ Person 3 & 1.99 & 3.28 & -0.25 & -0.28 & -1.12 & -1.38 & -0.04 & -0.07 & 1.20 & 1.80 \ Person 4 & 0.74 & 0.79 & 0.72 & 0.91 & 0.81 & 1.08 & -0.04 & -0.07 & -0.31 & -0.50 \ Person 5 & -0.12 & -0.21 & -0.06 & -0.05 & 0.15 & 0.07 & 0.39 & 0.58 & 0.83 & 1.08 \ Person 6 & 0.43 & 0.40 & 0.72 & 0.91 & 1.38 & 2.90 & 0.10 & 0.14 & -0.06 & -0.20 \ Person 7 & 1.99 & 3.28 & -0.90 & -1.18 & 0.57 & 0.65 & 0.70 & 1.16 & 0.83 & 1.08 \ Person 8 & -1.13 & -1.32 & -0.46 & -0.53 & 0.15 & 0.07 & 0.54 & 0.84 & 0.21 & 0.14 \ Person 9 & -1.40 & -1.66 & 1.68 & 2.89 & 1.08 & 1.69 & -0.33 & -0.50 & 0.83 & 1.08 \ Person 10& -0.62 & -0.74 & 0.33 & 0.40 & -1.27 & -1.56 & -0.78 & -1.34 & -0.77 & -1.01 \ \midrule[\heavyrulewidth] \multicolumn{11}{l}{E: Extraversion; N: Neurotizismus; O: Offenheit} \ \multicolumn{11}{l}{V: Verträglichkeit; G: Gewissenhaftigkeit} \end{tabular*}

\end{table}

\end{document}

enter image description here

egreg
  • 1,121,712