此外LyX 中的右居中列,我现在遇到了另一个问题,现在涉及多列。我想将数字“98”(横跨两列)置于其他两列的上方。这些列应“右居中”对齐(S[table-format=2.0])并且彼此“更近”。请参阅上面的代码和图像。
\begin{table}[H]
\centering
\begin{threeparttable}
\caption{\textbf{\label{tab:ms-soziodemographische-parameter}blabla}}
\begin{tabular}{lS[table-format=2.0]S[math-rm=\mathit,table-format=2.1,input-symbols=()]cc}
\toprule
& \multicolumn{2}{>{\centering}p{0.2\columnwidth}}{\textbf{Pat. mit Kopfschmerzen}} & \textbf{Pat. ohne Kopfschmerzen} & \textbf{p-Wert}\tabularnewline
\midrule
\midrule
\textbf{Anzahl} & \multicolumn{2}{c}{98} & 82 & \textbf{\textit{0,001}}\tabularnewline
\midrule
\textbf{Alter: Jahre (SD)} & 41 & (12,9) & 47,4 (12,6) & \textbf{\textit{0,001}}\tabularnewline
\midrule
\textbf{Geschlecht: n(\%)} & & & & \textbf{\textit{0,001}}\tabularnewline
- Weiblich & 78 & (79,6) & 47 (57,3) & \tabularnewline
- Männlich & 20 & (20,4) & 35 (42,7) & \tabularnewline
\midrule
\textbf{KD der MS: Jahre (SD)} & 11,2 & (8,6) & 13,7 (8,9) & 0,056\tabularnewline
\midrule
\textbf{Verlaufsform: n(\%)} & & & & \textbf{\textit{0,042}}\tabularnewline
- RRMS & 56 & (57,1) & 30 (36,6) & \tabularnewline
- SCP & 29 & (29,6) & 38 (46,3) & \tabularnewline
- PPMS & 11 & (11,2) & 13 (15,9) & \tabularnewline
- CIS & 2 & (2,0) & 1 (1,2) & \tabularnewline
\midrule
\end{tabular}
\end{threeparttable}
\end{table}
输出如下:
。
答案1
通过在列规范中添加table-number-alignment=center
(left
,其他选择为right
默认值),并删除说明符,可以使列更加居中。center-decimal-marker
table-format=x.y
98
(我不太明白发生了什么,因为根据手册,table-format
选项应该设置table-number-alignment
为。)center
\documentclass{article}
\usepackage{threeparttable}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{array}
\begin{document}
\begin{table}
\centering
\begin{threeparttable}
\caption{\textbf{\label{tab:ms-soziodemographische-parameter}blabla}}
\begin{tabular}{%
l
S[table-number-alignment=center]
S[math-rm=\mathit,input-symbols=(),table-number-alignment=center]
cc}
\toprule
& \multicolumn{2}{>{\centering}p{0.2\columnwidth}}{\textbf{Pat. mit Kopfschmerzen}} & \textbf{Pat. ohne Kopfschmerzen} & \textbf{p-Wert}\tabularnewline
\midrule
\midrule
\textbf{Anzahl} & \multicolumn{2}{c}{98} & 82 & \textbf{\textit{0,001}}\tabularnewline
\midrule
\textbf{Alter: Jahre (SD)} & 41 & (12,9) & 47,4 (12,6) & \textbf{\textit{0,001}}\tabularnewline
\midrule
\textbf{Geschlecht: n(\%)} & & & & \textbf{\textit{0,001}}\tabularnewline
- Weiblich & 78 & (79,6) & 47 (57,3) & \tabularnewline
- Männlich & 20 & (20,4) & 35 (42,7) & \tabularnewline
\midrule
\textbf{KD der MS: Jahre (SD)} & 11,2 & (8,6) & 13,7 (8,9) & 0,056\tabularnewline
\midrule
\textbf{Verlaufsform: n(\%)} & & & & \textbf{\textit{0,042}}\tabularnewline
- RRMS & 56 & (57,1) & 30 (36,6) & \tabularnewline
- SCP & 29 & (29,6) & 38 (46,3) & \tabularnewline
- PPMS & 11 & (11,2) & 13 (15,9) & \tabularnewline
- CIS & 2 & (2,0) & 1 (1,2) & \tabularnewline
\midrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
答案2
就我个人而言,我不得不说,改变“98”项的对齐方式和列间宽度不如避免当前彻底混淆列内容那么紧迫:根据行,列条目表示年份或样本大小,和/或标准差和百分比。我认为让读者感到困惑不是你的目的。:-)
我试图理清以下 MWE 中的内容。
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{lmodern,booktabs,threeparttable,siunitx}
\sisetup{locale=DE,table-format=2.1}
\begin{document}
\begin{table}
\centering
\begin{threeparttable}
\caption{blabla}
\label{tab:ms-soziodemographische-parameter}
\begin{tabular}{@{} l *{2}{S S[math-rm=\mathit]} r @{}}
\toprule
& \multicolumn{2}{>\centering p{0.18\columnwidth}}{\textbf{Pat. mit Kopfschmerzen}}
& \multicolumn{2}{>\centering p{0.18\columnwidth}}{\textbf{Pat. ohne Kopfschmerzen}}
& \textbf{p-Wert}\\
\midrule
& \multicolumn{1}{c}{Jahre}
& \multicolumn{1}{c}{\textit{SD}}
& \multicolumn{1}{c}{Jahre}
& \multicolumn{1}{c}{\textit{SD}} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5}
\textbf{Alter} & 41 & 12,9 & 47,4 & 12,6 & 0,001\\
\textbf{KD der MS} & 11,2 & 8,6 & 13,7 & 8,9 & 0,056\\
\addlinespace
\midrule
& \multicolumn{1}{l}{\ n}
& \multicolumn{1}{c}{\textit{\%}}
& \multicolumn{1}{l}{\ n}
& \multicolumn{1}{c}{\textit{\%}} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5}
\textbf{Anzahl} & 98 & & 82 & & 0,001 \\[1ex]
\textbf{Geschlecht} & & & & & 0,001 \\[0.25ex]
- Weiblich & 78 & 79,6 & 47 & 57,3 & \\
- M\"annlich & 20 & 20,4 & 35 & 42,7 & \\[1ex]
\textbf{Verlaufsform} & & & & & 0,042\\[0.25ex]
- RRMS & 56 & 57,1 & 30 & 36,6 & \\
- SCP & 29 & 29,6 & 38 & 46,3 & \\
- PPMS & 11 & 11,2 & 13 & 15,9 & \\
- CIS & 2 & 2,0 & 1 & 1,2 & \\
\midrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}