我正在尝试使用 Latex 打印我在 Stata 中制作的表格。
\documentclass[a4paper,article]{memoir}
\usepackage[danish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{esint}
\usepackage{dsfont}
\usepackage{mathtools}
\usepackage{amsmath, amssymb}
\usepackage{amsthm}
\usepackage[margin=1.5in]{geometry}
\usepackage{enumerate}
\usepackage{booktabs}
\usepackage{tabularx}
\pagestyle{plain}
\begin{document}
\begin{center}
\footnotesize
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{tabularx}{14cm} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}}
toprule
Patient died
To died or exp. end No No No Yes Yes Yes Total Total Total
No. Col \% Cum \% No. Col \% Cum \% No. Col \% Cum \%
10 or less months 4 23.5 23.5 15 48.4 48.4 19 39.6 39.6
11 to 20 months 6 35.3 58.8 8 25.8 74.2 14 29.2 68.8
21 to 30 months 2 11.8 70.6 7 22.6 96.8 9 18.8 87.5
31 or more months 5 29.4 100.0 1 3.2 100.0 6 12.5 100.0
Total 17 100.0 31 100.0 48 100.0
\bottomrule
\addlinespace[.75ex]
\end{tabularx}
\par
\scriptsize{\emph{Source: }cancer.dta}
\normalsize
\end{center}
\end{document}
我就是找不到错误,很抱歉,我几乎把所有的代码都放进去了,我只是想确保我没有错过任何东西
先感谢您
答案1
将您的表格转换为LaTeX
表格需要相当长的时间......并且我不确定转换是否没有错误:
\documentclass[a4paper,article]{memoir}
%\usepackage[danish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[margin=1.5in]{geometry}
\usepackage{booktabs,makecell,tabularx}
\pagestyle{plain}
\usepackage{siunitx}% <-- new
\begin{document}
\begin{center}
\setlength\tabcolsep{4pt}
\begin{tabularx}{14cm}{X *{9}{S[table-format=3.1]}}
\toprule
% Patient died
{To died or exp. end}
& {No} & {No} & {No} & {Yes} & {Yes} & {Yes} &{Total}&{Total} & {Total} \\
\midrule
No. Col \% & {\makecell{Cum\\ \%}}
& {\makecell{No. Col\\ \%}}
& {\makecell{Cum\\ \%}}
& {\makecell{No. Col\\ \%}}
& {\makecell{Cum\\ \%}}
& & & & \\
\midrule
10 or less months & 4 & 23.5 & 23.5 & 15 & 48.4 & 48.4 & 19 & 39.6 & 39.6 \\
11 to 20 months 6 & 35.3 & 58.8 & 8 & 25.8 & 74.2 & 14 & 29.2 & 68.8 & \\
21 to 30 months 2 & 11.8 & 70.6 & 7 & 22.6 & 96.8 & 9 & 18.8 & 87.5 & \\
31 or more months & 5 & 29.4 & 100.0 & 1 & 3.2 & 100.0 & 6 & 12.5 & 100.0 \\
Total & 17 & 100.0 & 31 & 100.0 & 48 & 100.0 & & & \\
\bottomrule
\addlinespace[.75ex]
\end{tabularx}
\par
\footnotesize{\emph{Source: }cancer.dta}
\end{center}
\end{document}
在上面的 MWE 中,我删除了所有未使用的包。为了使带数字的列更美观,我建议使用S
包中的列类型siunitx
。