變數描述表中的左對齊

變數描述表中的左對齊

我無法理解為什麼在下面的程式碼中(我知道我可能需要稍微修改一下序言),我無法左對齊「變數」。我嘗試了不同的解決方案,但它仍然居中。

另一個(次要且不太重要的)問題是我嘗試更改列的順序,將說明放在最後。但是我總是收到錯誤訊息。任何想法?

\documentclass[11pt]{article}
\usepackage{rotating}

\usepackage{longtable}
\usepackage[labelfont=bf, labelsep=newline, justification=centering, textfont=it]{caption}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{booktabs, makecell, siunitx}
\usepackage{eqparbox}
\pagenumbering{gobble}
\usepackage{booktabs}
\usepackage[referable,para]{threeparttablex}
\usepackage[a4paper,margin=1.5cm]{geometry}
\usepackage{multirow}
\usepackage{pdflscape}
\usepackage{stackengine}
\usepackage{interval}
\usepackage{amsmath,ragged2e} % <-- new
\usepackage{interval,pbox}

\usepackage{booktabs,tabularx}

\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***, 
table-number-alignment =center}
\newcommand*{\MyIndent}
{\hspace*{1.5cm}}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro

\newcommand\mytab[1]{%
   \smash[b]{\begin{tabular}[c]{@{}c@{}}#1\end{tabular}}}
\hyphenation{bur-kina}

\begin{document}

\begin{table}
\renewcommand{\arraystretch}{1.5} 

\caption{Descriptions of variables\label{A1}}
\begin{tabularx}{\textwidth}{@{}lXSS@{}}
\toprule
\multicolumn{1}{l}{Variables}&\mc{Description}&\mc{Mean}&\mc{SD}\\
\midrule
Health&Test of a really long description which should itself span many rows, in fact occupying much space, hopefully, causing it to span a couple of normal rows. Test of a really long description which should itself span many rows, in fact occupying much space, hopefully, causing it to span a couple of normal rows&\mc{0.8049}&\mc{0.3928}\\
Age&Test of a really long description which should itself span many rows, in fact occupying much space, hopefully, causing it to span a couple of normal rows&\mc{49.16}&\mc{15.82}\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

答案1

像這樣的東西嗎?

\documentclass[11pt]{article}
\usepackage{rotating}

\usepackage{longtable}
\usepackage[labelfont=bf, labelsep=newline, justification=centering, textfont=it]{caption}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{booktabs, makecell, siunitx}
\usepackage{eqparbox}
\pagenumbering{gobble}
\usepackage{booktabs}
\usepackage[referable,para]{threeparttablex}
\usepackage[a4paper,margin=1.5cm]{geometry}
\usepackage{multirow}
\usepackage{pdflscape}
\usepackage{stackengine}
\usepackage{interval}
\usepackage{amsmath,ragged2e} % <-- new
\usepackage{interval,pbox}

\usepackage{booktabs,tabularx}

\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***, 
table-number-alignment =center}
\newcommand*{\MyIndent}
{\hspace*{1.5cm}}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro

\newcommand\mytab[1]{%
   \smash[b]{\begin{tabular}[c]{@{}c@{}}#1\end{tabular}}}
\hyphenation{bur-kina}

\begin{document}

\begin{table}
\renewcommand{\arraystretch}{1.5} 

\caption{Descriptions of variables\label{A1}}
\begin{tabularx}{\textwidth}{@{}lXSS@{}}
\toprule
\multicolumn{1}{@{}l}{Variables}&\mc{Description}&\mc{Mean}&\mc{SD}\\ % @{} here
\midrule
Health&Test of a really long description which should itself span many rows, in fact occupying much space, hopefully, causing it to span a couple of normal rows. Test of a really long description which should itself span many rows, in fact occupying much space, hopefully, causing it to span a couple of normal rows&\mc{0.8049}&\mc{0.3928}\\
Age&Test of a really long description which should itself span many rows, in fact occupying much space, hopefully, causing it to span a couple of normal rows&\mc{49.16}&\mc{15.82}\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

在此輸入影像描述

相關內容