我可以让这张桌子适合纵向模式吗?

我可以让这张桌子适合纵向模式吗?

我有一张桌子,想让它适合纵向模式。你认为这可能吗?

以下是一个最简单的例子:

\documentclass[11pt,a4paper]{book}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage[width=0.00cm, height=0.00cm, left=1.00in, right=1.00in, top=1.00in, bottom=1.00in]{geometry}
\usepackage{threeparttable}
\usepackage{rotating}
\usepackage{booktabs}

\begin{document}

{\footnotesize
\begin{table}[H!]
%\begin{sidewaystable}[h!]
\centering
\begin{threeparttable}
\caption{OLS results } \label{ols_results}
\begin{tabular}{lcccccccc} \toprule
& \multicolumn{4}{c}{Non-HMO Hospitals} & \multicolumn{4}{c}{HMO-Hospitals} \\
\cmidrule(r){2-5} \cmidrule{6-9}
& \multicolumn{2}{c}{Doctors} & \multicolumn{2}{c}{Non-Doctors} & \multicolumn{2}{c}{Doctors} & \multicolumn{2}{c}{Non-Doctors} \\
\cmidrule(r){2-3} \cmidrule(r){4-5} \cmidrule(r){6-7} \cmidrule{8-9}

 & Mean &  StDev & Mean &  StDev & Mean &  StDev & Mean &  StDev \\ \midrule
\underline{Demographics}: &&&&&&&& \\
Age & 32.59* &  [4.00] & 31.13* &   [4.28] & 32.63* &   [4.12] & 30.69* &   [4.28] \\
Mother's Education ($\%$) &&&&&&&& \\ 
\hspace{0.2em} Some college &&&&&&&& \\
\hspace{0.2em} College graduate &&&&&&&& \\
\hspace{0.2em} High education &&&&&&&& \\
Father's education &&&&&&&& \\
\hspace{0.2em} Some college &&&&&&&& \\
\hspace{0.2em} College graduate &&&&&&&& \\
\hspace{0.2em} High education &&&&&&&& \\
Insurance ($\%$) &&&&&&&& \\
\hspace{0.2em} HMO &&&&&&&& \\
\hspace{0.2em} Government &&&&&&&& \\
\hspace{0.2em} Indigent &&&&&&&& \\
Placental/uterine rupture/haemorrhage & 1.44 & [0.23] &&&&&& \\ \midrule
Observations & \multicolumn{2}{c}{2360} & \multicolumn{2}{c}{7852} & \multicolumn{2}{c}{256} & \multicolumn{2}{c}{879}  \\
\bottomrule
\end{tabular}

\begin{tablenotes}
\tiny
\item[a] [whatever here, this is just a test] This table is made with the use if \LaTeXe{} . Cristobal is a port on the Atlantic side of the Panama Canal. It is located on the western edge of Manzanillo Island and is part of the Panamanian city and province of Colon. Cristobal Colon is the Spanish translation for Christopher Columbus, the Genovese explorer for whom these places were named.
\end{tablenotes}

\end{threeparttable}
%\end{sidewaystable}
\end{table}
}


\end{document}

答案1

您的示例中忽略footnotesize了 ,因为它在table环境之外。如果您将其移到内部,则 fnot 足够小,可以在页面中显示表格。

为了将其置于页面中心,我使用了答案是适合那些对于边距来说太大的框。但是,如果您的表格是浮动的,那么这将不起作用(但从您的判断来看,[H!]这可能不是太严重?)。其他更聪明的人可能会想出更好的解决方案,但这可能行得通。

\documentclass[11pt,a4paper]{book}
\usepackage[
  width=0.00cm,
  height=0.00cm,
  left=1.00in,
  right=1.00in,
  top=1.00in,
  bottom=1.00in,
  showframe
]{geometry}
\usepackage{threeparttable}
\usepackage{booktabs}

\newenvironment{xcenter}
{\par\setbox0=\hbox\bgroup\ignorespaces}
{\unskip\egroup\noindent\makebox[\textwidth]{\box0}\par}

\begin{document}

\begin{xcenter}
\footnotesize
% \centering
\begin{threeparttable}
\caption{OLS results } \label{ols_results}
\begin{tabular}{@{}lcccccccc@{}} \toprule
& \multicolumn{4}{c}{Non-HMO Hospitals} & \multicolumn{4}{c}{HMO-Hospitals} \\
\cmidrule(r){2-5} \cmidrule{6-9}
& \multicolumn{2}{c}{Doctors} & \multicolumn{2}{c}{Non-Doctors} & \multicolumn{2}{c}{Doctors} & \multicolumn{2}{c}{Non-Doctors} \\
\cmidrule(r){2-3} \cmidrule(r){4-5} \cmidrule(r){6-7} \cmidrule{8-9}

& Mean &  StDev & Mean &  StDev & Mean &  StDev & Mean &  StDev \\ 
\midrule
\underline{Demographics}: &&&&&&&& \\
Age & 32.59* &  [4.00] & 31.13* &   [4.28] & 32.63* &   [4.12] & 30.69* &   [4.28] \\
Mother's Education ($\%$) &&&&&&&& \\ 
\hspace{0.2em} Some college &&&&&&&& \\
\hspace{0.2em} College graduate &&&&&&&& \\
\hspace{0.2em} High education &&&&&&&& \\
Father's education &&&&&&&& \\
\hspace{0.2em} Some college &&&&&&&& \\
\hspace{0.2em} College graduate &&&&&&&& \\
\hspace{0.2em} High education &&&&&&&& \\
Insurance ($\%$) &&&&&&&& \\
\hspace{0.2em} HMO &&&&&&&& \\
\hspace{0.2em} Government &&&&&&&& \\
\hspace{0.2em} Indigent &&&&&&&& \\
Placental/uterine rupture/haemorrhage & 1.44 & [0.23] &&&&&& \\ 
\midrule
Observations & \multicolumn{2}{c}{2360} & \multicolumn{2}{c}{7852} & \multicolumn{2}{c}{256} & \multicolumn{2}{c}{879}  \\
\bottomrule
\end{tabular}

\begin{tablenotes}
\tiny
\item[a] [whatever here, this is just a test] This table is made with the use if \LaTeXe{} . Cristobal is a port on the Atlantic side of the Panama Canal. It is located on the western edge of Manzanillo Island and is part of the Panamanian city and province of Colon. Cristobal Colon is the Spanish translation for Christopher Columbus, the Genovese explorer for whom these places were named.
\end{tablenotes}

\end{threeparttable}
\end{xcenter}

\end{document}

在此处输入图片描述

答案2

如果您愿意在倒数第二行 ( ) 的标题中留出换行符Placental/uterine rupture/haemorrhage,则可以通过将第一列(即最左侧的列)的类型从 更改为 ,使表格适合纵向模式的文本块lp{4cm}为什么是 4 厘米?这样,下一个最长的标题Mother's Education (\%)就可以适合可用空间。请注意,不再需要减小字体大小。

我还建议对 s 进行更系统的修剪\cmidrule,以使标题行的结构更加不言而喻。并且,为了遵循贯穿整个软件包的总体设计理念booktabs,我将删除第一列左侧和最后一列右侧的空白。一种方法是使用环境tabular*,将其设置\tabcolsep为 0pt,然后让 LaTeX 确定多少列间空白是最佳的。

下图左侧和右侧的细线表示文本块的边缘;这些线是通过包showframe的选项插入的geometry

在此处输入图片描述

\documentclass[11pt,a4paper]{book}
\usepackage[margin=1in,showframe]{geometry}
\usepackage{threeparttable,booktabs}
\begin{document}

\begin{table}
\centering
\begin{threeparttable}
\setlength\tabcolsep{0pt}
\caption{OLS results} \label{ols_results}
\begin{tabular*}{\textwidth}{ p{4cm} @{\extracolsep{\fill}} cccccccc } 
\toprule
& \multicolumn{4}{c}{Non-HMO Hospitals} 
& \multicolumn{4}{c}{HMO-Hospitals} \\
\cmidrule(lr){2-5} \cmidrule(l){6-9}
& \multicolumn{2}{c}{Doctors} & \multicolumn{2}{c}{Non-Doctors} 
& \multicolumn{2}{c}{Doctors} & \multicolumn{2}{c}{Non-Doctors} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(l){8-9}
 & Mean &  StDev & Mean &  StDev 
 & Mean &  StDev & Mean &  StDev \\ 
\midrule
\underline{Demographics}: &&&&&&&& \\
Age & 32.59* &  [4.00] & 31.13* &   [4.28] & 32.63* &   [4.12] & 30.69* &   [4.28] \\
Mother's Education (\%) &&&&&&&& \\
\hspace{0.2em} Some college &&&&&&&& \\
\hspace{0.2em} College graduate &&&&&&&& \\
\hspace{0.2em} High education &&&&&&&& \\
Father's education &&&&&&&& \\
\hspace{0.2em} Some college &&&&&&&& \\
\hspace{0.2em} College graduate &&&&&&&& \\
\hspace{0.2em} High education &&&&&&&& \\
Insurance (\%) &&&&&&&& \\
\hspace{0.2em} HMO &&&&&&&& \\
\hspace{0.2em} Government &&&&&&&& \\
\hspace{0.2em} Indigent &&&&&&&& \\
\raggedright Placental\slash uterine rupture\slash 
   haemorrhage & 1.44 & [0.23] &&&&&& \\ 
\midrule
Observations 
& \multicolumn{2}{c}{2360} & \multicolumn{2}{c}{7852} 
& \multicolumn{2}{c}{256} & \multicolumn{2}{c}{879}  \\
\bottomrule
\end{tabular*}  
\begin{tablenotes}
\footnotesize
\item[a] [whatever here, this is just a test] This table is made with the use of \LaTeXe. Cristobal is a port on the Atlantic side of the Panama Canal. It is located on the western edge of Manzanillo Island and is part of the Panamanian city and province of Colon. Cristobal Colon is the Spanish translation for Christopher Columbus, the Genoese explorer for whom these places were named.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document} 

相关内容