如何将此表放入页面中?同时将文本垂直对齐到中心

如何将此表放入页面中?同时将文本垂直对齐到中心

我希望这个表格适合页面宽度。另外,将内容垂直对齐到框的中心。请参阅下表的代码。

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{mathtools}
\usepackage{tabularx}
\usepackage{multirow}

\begin{document}

\begin{table}[h!]
\begin{tabular}{|c|c|c|r|r|r|r|r|r|r|r|}
\hline
\multicolumn{2}{|c|}{\multirow{2}{*}{Heading 1}} & \multicolumn{9}    {c|}{$\theta$} \\ \cline{3-11} 
\multicolumn{2}{|c|}{} & \multicolumn{3}{c|}{1} & \multicolumn{3}{c|}{1.5}                                                        & \multicolumn{3}{c|}{2}\\ \hline \multicolumn{2}{|c|}{$\alpha\Rightarrow$} & 0.1 & \multicolumn{1}{c|}{0.2} & \multicolumn{1}{c|}{0.3} & \multicolumn{1}{c|}{0.1} & \multicolumn{1}{c|}{0.2} & \multicolumn{1}{c|}{0.3} & \multicolumn{1}{c|}{0.1} & \multicolumn{1}{c|}{0.2} & \multicolumn{1}{c|}{0.3} \\ \hline
\multirow{3}{*}{x1/x2} & 1/3 & \multicolumn{1}{r|}{34.38\%} & 16.95\% & 9.74\% & 87.58\% & 36.25\%  & 45.85\% & 30.10\% & 67.21\% & 59.25\% \\ \cline{2-11} 
& 1 & \multicolumn{1}{r|}{61.52\%} & 79.96\%  & 68.17\% & 75.50\%  & 36.18\% & 48.46\% & 32.88\% & 29.26\% & 9.76\% \\ \cline{2-11}
& 3 & \multicolumn{1}{r|}{53.70\%} & 68.99\% & 85.41\%  & 37.80\% & 85.88\% & 25.70\%  & 32.32\% & 93.95\% & 81.96\% \\ \hline
\end{tabular}
\end{table}
\end{document} 

答案1

您可以使用 的值\tabcolsep并稍微重新组织表格,在自己的行上插入唯一的 % 符号,使其适合页面。我还加载了 包makecell,它允许简化列标题的代码,并在单元格的顶部和底部添加一些垂直填充。

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{tabularx, multirow, makecell}

\begin{document}

\begin{table}[h!]
\centering%
\setlength{\tabcolsep}{4pt}
\setcellgapes{4pt}\makegapedcells
\begin{tabular}{|c|c|*{9}{r|}}
\hline
\multicolumn{2}{|c|}{\multirowcell{2}{Heading\\1}} & \multicolumn{9} {c|}{$\theta$} \\ \cline{3-11}
\multicolumn{2}{|c|}{} & \multicolumn{3}{c|}{1} & \multicolumn{3}{c|}{1.5} & \multicolumn{3}{c|}{2}\\ \hline \multicolumn{2}{|c|}{$\alpha\Rightarrow$} &\makecell{ 0.1} & \makecell{0.2} & \makecell{0.3} & \makecell{0.1} & \makecell{0.2} & \makecell{0.3} & \makecell{0.1} & \makecell{0.2} & \makecell{0.3} \\ \hline
\multicolumn{2}{|c}{} & \multicolumn{9}{c|}{\%} \\
\hline
\multirowcell{3.5}{$\dfrac{x1}{x2}$} & 1/3 & 34.38 & 16.95 & 9.74 & 87.58 & 36.25 & 45.85 & 30.10 & 67.21 & 59.25 \\ \cline{2-11}
& 1 & 61.52 & 79.96 & 68.17 & 75.50 & 36.18 & 48.46 & 32.88 & 29.26 & 9.76 \\ \cline{2-11}
& 3 & 53.70 & 68.99 & 85.41 & 37.80 & 85.88 & 25.70 & 32.32 & 93.95 & 81.96 \\ \hline
\end{tabular}
\end{table}

\end{document} 

在此处输入图片描述

答案2

这是我最终用到的。

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{tabularx, multirow, makecell}

\begin{document}

\begin{table}[h!]
\centering%
\setlength{\tabcolsep}{4pt}
\setcellgapes{4pt}\makegapedcells
\begin{tabular}{|c|c|*{9}{r|}}
\hline
\multicolumn{2}{|c|}{\multirowcell{2}{Heading 1\\(\%)}} & \multicolumn{9} {c|}{$\theta$} \\ \cline{3-11}
\multicolumn{2}{|c|}{} & \multicolumn{3}{c|}{1} & \multicolumn{3}{c|}{1.5} & \multicolumn{3}{c|}{2}\\ \hline \multicolumn{2}{|c|}{$\alpha\Rightarrow$} &\makecell{ 0.1} & \makecell{0.2} & \makecell{0.3} & \makecell{0.1} & \makecell{0.2} & \makecell{0.3} & \makecell{0.1} & \makecell{0.2} & \makecell{0.3} \\ \hline
\multirowcell{3}{$\dfrac{x1}{x2}$} & 1/3 & 34.38 & 16.95 & 9.74 & 87.58 & 36.25 & 45.85 & 30.10 & 67.21 & 59.25 \\ \cline{2-11}
& 1 & 61.52 & 79.96 & 68.17 & 75.50 & 36.18 & 48.46 & 32.88 & 29.26 & 9.76 \\ \cline{2-11}
& 3 & 53.70 & 68.99 & 85.41 & 37.80 & 85.88 & 25.70 & 32.32 & 93.95 & 81.96 \\ \hline
\end{tabular}
\end{table}

\end{document} 

图像

答案3

这是一个 wrapfig 解决方案。由于这会占用整个页面,因此您可能最终会将其插入到段落的中间。

请注意,顶部\intextsep被页面顶部吸收了。不要指望这一点。

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}% not used
\usepackage{mathtools}% not used
\usepackage{tabularx}% not used
\usepackage{multirow}
\usepackage{graphics}% for \rotatebox
\usepackage{wrapfig}
\usepackage{showframe}% debugging tool
\usepackage{lipsum}% debugging tool

\begin{document}

\begin{wraptable}{r}{0pt}
\rotatebox{90}{\begin{minipage}{\dimexpr\textheight-2\intextsep}
\caption{Test}
\centering
\begin{tabular}{|c|c|c|r|r|r|r|r|r|r|r|}
\hline
\multicolumn{2}{|c|}{\multirow{2}{*}{Heading 1}} & \multicolumn{9}    {c|}{$\theta$} \\ \cline{3-11} 
\multicolumn{2}{|c|}{} & \multicolumn{3}{c|}{1} & \multicolumn{3}{c|}{1.5}                                                        & \multicolumn{3}{c|}{2}\\ \hline \multicolumn{2}{|c|}{$\alpha\Rightarrow$} & 0.1 & \multicolumn{1}{c|}{0.2} & \multicolumn{1}{c|}{0.3} & \multicolumn{1}{c|}{0.1} & \multicolumn{1}{c|}{0.2} & \multicolumn{1}{c|}{0.3} & \multicolumn{1}{c|}{0.1} & \multicolumn{1}{c|}{0.2} & \multicolumn{1}{c|}{0.3} \\ \hline
\multirow{3}{*}{x1/x2} & 1/3 & \multicolumn{1}{r|}{34.38\%} & 16.95\% & 9.74\% & 87.58\% & 36.25\%  & 45.85\% & 30.10\% & 67.21\% & 59.25\% \\ \cline{2-11} 
& 1 & \multicolumn{1}{r|}{61.52\%} & 79.96\%  & 68.17\% & 75.50\%  & 36.18\% & 48.46\% & 32.88\% & 29.26\% & 9.76\% \\ \cline{2-11}
& 3 & \multicolumn{1}{r|}{53.70\%} & 68.99\% & 85.41\%  & 37.80\% & 85.88\% & 25.70\%  & 32.32\% & 93.95\% & 81.96\% \\ \hline
\end{tabular}
\end{minipage}}
\end{wraptable}

\lipsum[1-3]
\end{document} 

完整页面

相关内容