0

I want this table to fit the page width. Also, vertially align the content to center of the box. Please find the code for the table below.

\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} 
Bernard
  • 271,350
MKC
  • 93

3 Answers3

1

You can make it fit the page playing with the value of \tabcolsep and slightly re-organising the table, inserting a unique % symbol on a line of its own. I also laded package makecell, which allows to simplify the code for the column heads, and add somme vertical padding at the top and bottom of cells.

\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} 

enter image description here

Bernard
  • 271,350
1

This is what I used finally.

\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} 

Image

MKC
  • 93
0

Here is a wrapfig solution. Since this takes the entire page, you will probably wind up inserting it into the middle of a paragraph.

Note that the top \intextsep got absorbed by the top of the page. Don't count on this.

\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} 

full page

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thank you. Actually, there are two tables of same dimensions one after another. I would have preferred a horizontal one so that is is easy to read and compare. – MKC Aug 16 '18 at 16:25