3

I am using a multicolumn at the end of my table to indicate what some of the abbreviations mean. I have enough of them that I need to wrap the text so I am using a paragraph column with centering defined. However, I noticed when I do not use the full textwidth, that the contents of the multicolumn is not centered as I would expect. Any way to fix this? MWE is below.

\documentclass{article}

\usepackage{tabularx,array,multirow}
\usepackage{booktabs}
\usepackage{caption}

\newcolumntype{P}[1]{>{\footnotesize\centering\arraybackslash}m{#1}}

\begin{document}

\noindent\begin{table}[!htbp]
\captionsetup{justification=centering}
\caption{Characteristics of Patients\label{tab:ptChar}}
\centering
\begin{tabularx}{\textwidth}{P{0.15\textwidth}
                             >{\footnotesize\centering\arraybackslash}X 
                             >{\footnotesize\centering\arraybackslash}X
                             >{\footnotesize\centering\arraybackslash}X
                             >{\footnotesize\centering\arraybackslash}X}
\toprule[1.5pt]
Characteristic & Patients (n=132) & $>$30\% (n=11) & $<$30\% (n=92) & p \\
\midrule

\raggedright Mean Age at Pathologic Diagnosis & 54.8 & 51.6 & 55.1 & 0.47* \\

\raggedright Ethnicity &  &  &  & 1.00\textsuperscript{\#} \\

\raggedright \hangindent=3mm \hangafter=0 Caucasian        & 76 &
 \shortstack{6 \\ (55\%)} & \shortstack{52 \\ (57\%)} & \\

\raggedright \hangindent=3mm \hangafter=0 African American & 45 &
 \shortstack{4 \\ (36\%)} & \shortstack{30 \\ (33\%)} & \\

\raggedright \hangindent=3mm \hangafter=0 NA               & 11 &
 \shortstack{1 \\ (9\%)}  & \shortstack{10 \\ (11\%)} & \\

\bottomrule[1.5pt]
\multicolumn{5}{P{0.8\textwidth}}{sfkdjkjke: lkjdfkljkljflasf; ioawejroias: kjskldfj.asdjf.; pval: p-value; *: Wilcoxon test; \textsuperscript{\#}: Fisher's Exact Test; NA: missing data }\\
\end{tabularx}
\end{table}

\end{document}

enter image description here

4

You can vastly simplify your input:

\documentclass{article}

\usepackage{array}
\usepackage{booktabs}
\usepackage{caption}

\newcommand{\splitcell}[2][c]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}

\begin{document}

\begin{table}[!htbp]
\centering\footnotesize

\caption{Characteristics of Patients\label{tab:ptChar}}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lcccc@{}}
\toprule
Characteristic & Patients ($n=132$) & $>30\%$ ($n=11$) & $<30\%$ ($n=92$) & p \\
\midrule

\splitcell[l]{Mean Age at \\ Pathologic \\ Diagnosis} & 54.8 & 51.6 & 55.1 & 0.47* \\

\addlinespace

Ethnicity &  &  &  & 1.00\textsuperscript{\#} \\

\quad Caucasian        & 76 &
 \splitcell{6 \\ (55\%)} & \splitcell{52 \\ (57\%)} & \\

\quad \splitcell[l]{African \\ American} & 45 &
 \splitcell{4 \\ (36\%)} & \splitcell{30 \\ (33\%)} & \\

\quad NA               & 11 &
 \splitcell{1 \\ (9\%)}  & \splitcell{10 \\ (11\%)} & \\

\midrule[\heavyrulewidth]
\multicolumn{5}{@{}c@{}}{%
  \parbox{0.8\textwidth}{\centering sfkdjkjke: lkjdfkljkljflasf; 
  ioawejroias: kjskldfj.asdjf.; pval:~p-value; *:~Wilcoxon test; 
  \textsuperscript{\#}:~Fisher's Exact Test; NA:~missing data}}\\
\end{tabular*}

\end{table}

\end{document}

Don't overuse tabularx. Also, try \small instead of \footnotesize; if it fits it makes for a more readable output.

enter image description here

|improve this answer|||||
2

With use of the makecell, threeparttable and siunitx packages:

\documentclass{article}
\usepackage[skip=1ex]{caption}
\usepackage{booktabs, 
            makecell,                   % new
            tabularx}
\usepackage[referable]{threeparttablex} % new
\usepackage{siunitx}                    % new

\begin{document}
    \begin{table}[!htb]  
\begin{threeparttable}
    \caption{Characteristics of Patients}
    \label{tab:ptChar}
\small
    \sisetup{input-comparators=<>,
             input-symbols = {( )},
             table-space-text-pre={(},
             table-space-text-post={\#},
             table-align-text-post=false}
    \setTableNoteFont{\footnotesize}
\begin{tabularx}{0.9\textwidth}{@{}>{\raggedright}X 
                        *{3}{S[table-format=2.1]}
                             S[table-format=1.2]
                             @{}}
    \toprule
Characteristic  &   {\makecell[t]{Patients\\ (n=132)}} 
                    &   {\makecell[t]{\SI{> 30}{\%}\\ (n=11)}} 
                        &   {\makecell[t]{\SI{< 30}{\%}\\ (n=92)}} 
                            &   {p value}\\
    \midrule
Mean Age at Pathologic Diagnosis 
    & 54.8  & 51.6      & 55.1      & 0.47\tnote{*}     \\
    \addlinespace 
Ethnicity 
    &       &           &           & 1.00\tnote{\#}    \\
\quad   Caucasian        
    & 76    & 6         & 52        &                   \\
    &       & (55\,\%)  & (57\,\%)  &                   \\
\quad   African American 
    & 45    & 4         & 30        &                   \\
    &       & (36\,\%)  & (33\,\%)  &                   \\
\quad   NA  
    & 11    & 1         & 10        &                   \\
    &       & (9\,\%)   & (91\,\%)  &                   \\
\bottomrule
\end{tabularx}
\begin{tablenotes}[para]\centering
\note lkjdfkljkljflasf; ioawejroias: kjskldfj.asdjf.; NA:   missing data\\
       p-values:
       \item[*]:    Wilcoxon test,
       \item[\#]:   Fisher's Exact Test,    
\end{tablenotes}
\end{threeparttable}
    \end{table}
\end{document}     

enter image description here

|improve this answer|||||
1

It is unnecessary to start a table-environment with \noindent. I also suggest you remove the side bearings to the left and right of you tabular.

You can use nested tabular inside the last multicolumn. The multicolumn shall have the full width of the table and be centred. I use a fixed width wc column. The nested table has one columns 0.8\linewidth.

enter image description here

\documentclass{article}

\usepackage{tabularx,array,multirow}
\usepackage{booktabs}
\usepackage{caption}

\newcolumntype{P}[1]{>{\footnotesize\centering\arraybackslash}m{#1}}

\begin{document}

\begin{table}[!htbp]  %% <-- Remove \noindent
\captionsetup{justification=centering}
\caption{Characteristics of Patients\label{tab:ptChar}}
\centering
\begin{tabularx}{\textwidth}{@{}P{0.15\textwidth}
                             >{\footnotesize\centering\arraybackslash}X 
                             >{\footnotesize\centering\arraybackslash}X
                             >{\footnotesize\centering\arraybackslash}X
                             >{\footnotesize\centering\arraybackslash}X@{}}
\toprule[1.5pt]
Characteristic & Patients (n=132) & $>$30\% (n=11) & $<$30\% (n=92) & p \\
\midrule

\raggedright Mean Age at Pathologic Diagnosis & 54.8 & 51.6 & 55.1 & 0.47* \\

\raggedright Ethnicity &  &  &  & 1.00\textsuperscript{\#} \\

\raggedright \hangindent=3mm \hangafter=0 Caucasian        & 76 &
 \shortstack{6 \\ (55\%)} & \shortstack{52 \\ (57\%)} & \\

\raggedright \hangindent=3mm \hangafter=0 African American & 45 &
 \shortstack{4 \\ (36\%)} & \shortstack{30 \\ (33\%)} & \\

\raggedright \hangindent=3mm \hangafter=0 NA               & 11 &
 \shortstack{1 \\ (9\%)}  & \shortstack{10 \\ (11\%)} & \\

\bottomrule[1.5pt]
\multicolumn{5}{wc{\linewidth}}{\begin{tabular}{@{}P{0.8\linewidth}@{}}
sfkdjkjke: lkjdfkljkljflasf; ioawejroias: kjskldfj.asdjf.; pval: p-value; *:~Wilcoxon test; \textsuperscript{\#}:~Fisher's Exact Test; NA:~missing data\\
\end{tabular}}
\end{tabularx}
\end{table}

\end{document}
|improve this answer|||||

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.