How to add index outside a table like this?
Thanks!
Going out on a limb here, I assume you want to create the indeces in the smaller font size...
I extended the table and reduzed the font size for the indeces. Using the array package for the rest.
Minimal working the solution:
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}
\centering
\begin{tabular}{ccccc}
& {\scriptsize 1} & {\scriptsize 2} & {\scriptsize 3} & {\scriptsize 4} \\ \cline{2-5}
{\scriptsize 1} & \multicolumn{1}{|c|}{0} &\multicolumn{1}{|c|}{ }& \multicolumn{1}{|c|}{-2}& \multicolumn{1}{|c|}{ } \\ \cline{2-5}
{\scriptsize 2} & \multicolumn{1}{|c|}{ } &\multicolumn{1}{|c|}{0}& \multicolumn{1}{|c|}{ } & \multicolumn{1}{|c|}{ } \\ \cline{2-5}
{\scriptsize 3} & \multicolumn{1}{|c|}{ } &\multicolumn{1}{|c|}{ }& \multicolumn{1}{|c|}{0} & \multicolumn{1}{|c|}{ } \\ \cline{2-5}
{\scriptsize 4} & \multicolumn{1}{|c|}{ } &\multicolumn{1}{|c|}{ }& \multicolumn{1}{|c|}{ } & \multicolumn{1}{|c|}{0} \\ \cline{2-5}
\end{tabular}
\end{table}
\end{document}
With the following result:
You can choose a different font size for the indices, like \small, \footnotesize or \tiny.
A basic version trying to reduce the number of multicolumns used may be:
\documentclass{article}
\begin{document}
\begin{tabular}{*{5}{c|}}
\multicolumn{1}{c}{ } & \multicolumn{1}{c}{1} & \multicolumn{1}{c}{2} & \multicolumn{1}{c}{3} & \multicolumn{1}{c}{4}\\\cline{2-5}
1 & 0 & & -2 & \\\cline{2-5}
2 & & 0 & & \\\cline{2-5}
3 & & & 0 & \\\cline{2-5}
4 & & & & 0 \\\cline{2-5}
\end{tabular}
\end{document}
Related
I have the following code which worked in my previous latex template, but now I have to submit to a journal and the tables goes out of the margin. I tried to use \resizebox{\textwidth}{!}{% ...} it does work. I have attached the code below for help.
\documentclass[10pt, twoside]{article}
\usepackage[b5j,hmargin={1 in,0.6 in},vmargin={1 in,0.6 in}]{geometry}
\usepackage{times}
\usepackage[labelsep=space, labelfont=bf]{caption}
\usepackage{amsmath,amssymb,amsthm,latexsym}
\begin{document}
\begin{table}[htbp]
\caption{Parameter estimates }
\label{tab:Application_MOTLOBXL1}
\begin{tabular}{lccccccccccccc}
\hline
Distribution & \multicolumn{4}{c}{Estimates} & -2Log(L) & AIC & AICC & BIC & $W^{*}$ & $A^{*}$ & K-S & P-value & SS \\ \hline
MOTLOBX-L & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 2.62$\times 10^{-3}$\\ (8.33$\times 10^{-4}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 1.21$\times 10^{1}$\\ (2.94$\times 10^{-4}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\delta$\\ 1.06$\times 10^{3}$\\ (1.41$\times 10^{-9}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 1.13\\ (5.42$\times 10^{-2}$)\end{tabular} & 24.4 & 32.4 & 33.1 & 41.0 & 0.0639 & 0.3929 & 0.0891 & 0.6998 & 0.0581 \\ \hline
MOTLOBX-W & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 5.71$\times 10^{-3}$\\ (2.01$\times 10^{-3}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 8.45$\times 10^{1}$\\ (6.09$\times 10^{-6}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\delta$\\ 8.12$\times 10^{2}$\\ (1.28$\times 10^{-8}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\lambda$\\ 3.61$\times 10^{-1}$\\ (2.07$\times 10^{-2}$)\end{tabular} & 25.1 & 33.1 & 33.8 & 41.7 & 0.1076 & 0.6042 & 0.0971 & 0.5928 & 0.0840 \\ \hline
WL & \begin{tabular}[c]{#{}c#{}}$a$\\ 3.29$\times 10^{-1}$\\ (6.38$\times 10^{-2}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$b$\\ 3.97\\ (3.85$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 7.24$\times 10^{3}$\\ (6.30$\times 10^{-5}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 1.41$\times 10^{4}$\\ (3.25$\times 10^{-5}$)\end{tabular} & 29.1 & 37.1 & 37.8 & 45.6 & 0.1962 & 1.0892 & 0.1425 & 0.1544 & 0.1813\\ \hline
GBXII & \begin{tabular}[c]{#{}c#{}}$a$\\ 3.01$\times 10^{-2}$\\ (3.27$\times 10^{-2}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$b$\\ 1.42\\ (5.97$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$c$\\ 1.57\\ (5.42$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 3.22\\ (1.87)\end{tabular} & 28.0 & 36.0 & 36.7 & 44.6 & 0.1616 & 0.9076 & 0.1318 & 0.2240 & 0.1504\\ \hline
MOOBII-Lo & \begin{tabular}[c]{#{}c#{}}$\delta$\\ 4.51$\times 10^{2}$\\ (4.34$\times 10^{-6}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 1.96\\ (1.71$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 9.20$\times 10^{-2}$\\ (4.17$\times 10^{-2}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\lambda$\\ 4.45\\ (7.51$\times 10^{-2}$)\end{tabular} & 40.4 & 48.4 & 49.1 & 57.0 & 0.3724 & 2.0787 & 0.1412 & 0.1619 & 0.2428\\ \hline
MOOBII-L & \begin{tabular}[c]{#{}c#{}}$\delta$\\ 7.08$\times 10^{2}$\\ (1.74$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 1.07$\times 10^{2}$\\ (3.24$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 1.14$\times 10^{1}$\\ (1.14$\times 10^{1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\lambda$\\ 1.84$\times 10^{1}$\\ (1.89)\end{tabular} & 32.0 & 40.0 & 40.7 & 48.6 & 0.2639 & 1.4517 & 0.1257 & 0.2727 & 0.1704\\ \hline
TLOBX-L & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 3.17$\times 10^{-1}$\\ (1.56$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 1.99$\times 10^{1}$\\ (8.88)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 9.13$\times 10^{-1}$\\ (6.17$\times 10^{-2}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}} - \end{tabular} & 42.3 & 48.3 & 48.7 & 54.7 & 0.4676 & 2.5657 & 0.2280 & 0.0029 & 0.6164 \\ \hline
TL-L & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 4.22$\times 10^{-1}$\\ (2.96$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 9.53\\ (5.85)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 3.53\\ (3.85$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}} - \end{tabular} & 62.6 & 68.6 & 69.0 & 75.0 & 0.6755 & 3.6946 & 0.3781 & $<0.0001$ & 2.4809 \\ \hline
MO-L & \begin{tabular}[c]{#{}c#{}}$\delta$\\ 2.85$\times 10^{1}$\\ (1.27$\times 10^{1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 7.92\\ (8.73$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}-\end{tabular} & \begin{tabular}[c]{#{}c#{}} - \end{tabular} & 45.6 & 49.6 & 49.8 & 53.9 & 0.4969 & 2.7489 & 0.1537 & 0.1019
& 0.3005 \\ \hline
OBX-L & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 5.83\\ (7.73$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 1.03\\ (6.09$\times 10^{-2}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}-\end{tabular} & \begin{tabular}[c]{#{}c#{}} - \end{tabular} & 45.6 & 51.7 & 51.9 & 56.0 & 0.5629 & 3.0915 & 0.2313 & 0.0024 & 0.6509 \\ \hline
\end{tabular}%
\end{table}
\end{document}
I am not sure if you have already submitted but I'd have a few improvements for you. Mostly, I changed to slightly better rules, formatted numbers and added extra vertical spaces for better presentation (also see the comments in the code)
\documentclass[10pt, twoside]{article}
\usepackage[b5j,hmargin={1 in,0.6 in},vmargin={1 in,0.6 in}]{geometry}
\usepackage{array}
\usepackage{times}
\usepackage{caption}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{rotating}
% sidwaystable environment does not rotate pages when viewing PDFs
% In twoside documents and no option is given to the package,
% sidewaystable rotates table such that bottom edge is facing outer margin.
% figuresright - bottom edge always turned to the right
% figureleft - bottom edge always turned to the left
\usepackage{booktabs} % improved rules
\usepackage{siunitx} % S type column to formnat numbers
\captionsetup[table]{
skip=3pt,
position=top,
labelsep=space,
labelfont=bf,
}
\sisetup{
round-mode=places,
round-precision=2,
table-format=1.2,
}
\newcommand\mlrule{\midrule[\cmidrulewidth]}
\begin{document}
\begin{sidewaystable}[htbp]
\renewcommand*{\arraystretch}{1.05}
\setlength\extrarowheight{-3pt}
\small
\centering
\caption{Parameter estimates}\label{tab:Application_MOTLOBXL1}
\begin{tabular}{l *8{c} *5{S}}
\toprule\rule[-4pt]{0pt}{13pt}
Distribution & \multicolumn{4}{c}{Estimates} & -2Log(L) & AIC & AICC & BIC & {$W^{*}$} & {$A^{*}$} & {K-S} & {P-value} & {SS} \\ \midrule
MOTLOBX-L
& \begin{tabular}[c]{#{}c#{}}
$\alpha$ \\
2.62$\times 10^{-3}$\\
(8.33$\times 10^{-4}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\theta$ \\
1.21$\times 10^{1}$ \\
(2.94$\times 10^{-4}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\delta$ \\
1.06$\times 10^{3}$ \\
(1.41$\times 10^{-9}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\beta$ \\
1.13 \\
(5.42$\times 10^{-2}$)
\end{tabular} & 24.4 & 32.4 & 33.1 & 41.0 & 0.0639 & 0.3929 & 0.0891 & 0.6998 & 0.0581 \\ \mlrule
MOTLOBX-W
& \begin{tabular}[c]{#{}c#{}}
$\alpha$ \\
5.71$\times 10^{-3}$ \\
(2.01$\times 10^{-3}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\theta$ \\
8.45$\times 10^{1}$ \\
(6.09$\times 10^{-6}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\delta$ \\
8.12$\times 10^{2}$ \\
(1.28$\times 10^{-8}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\lambda$ \\
3.61$\times 10^{-1}$ \\
(2.07$\times 10^{-2}$)
\end{tabular} & 25.1 & 33.1 & 33.8 & 41.7 & 0.1076 & 0.6042 & 0.0971 & 0.5928 & 0.0840 \\ \mlrule
WL
& \begin{tabular}[c]{#{}c#{}}
$a$ \\
3.29$\times 10^{-1}$ \\
(6.38$\times 10^{-2}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$b$ \\
3.97 \\
(3.85$\times 10^{-1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\alpha$ \\
7.24$\times 10^{3}$ \\
(6.30$\times 10^{-5}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\beta$ \\
1.41$\times 10^{4}$ \\
(3.25$\times 10^{-5}$)
\end{tabular} & 29.1 & 37.1 & 37.8 & 45.6 & 0.1962 & 1.0892 & 0.1425 & 0.1544 & 0.1813 \\ \mlrule
GBXII
& \begin{tabular}[c]{#{}c#{}}
$a$ \\
3.01$\times 10^{-2}$ \\
(3.27$\times 10^{-2}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$b$ \\
1.42 \\
(5.97$\times 10^{-1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$c$ \\
1.57 \\
(5.42$\times 10^{-1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\theta$ \\
3.22 \\
(1.87)
\end{tabular} & 28.0 & 36.0 & 36.7 & 44.6 & 0.1616 & 0.9076 & 0.1318 & 0.2240 & 0.1504 \\ \mlrule
MOOBII-Lo
& \begin{tabular}[c]{#{}c#{}}
$\delta$ \\
4.51$\times 10^{2}$ \\
(4.34$\times 10^{-6}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\alpha$ \\
1.96 \\
(1.71$\times 10^{-1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\beta$ \\
9.20$\times 10^{-2}$ \\
(4.17$\times 10^{-2}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\lambda$ \\
4.45 \\
(7.51$\times 10^{-2}$)
\end{tabular} & 40.4 & 48.4 & 49.1 & 57.0 & 0.3724 & 2.0787 & 0.1412 & 0.1619 & 0.2428 \\ \mlrule
MOOBII-L
& \begin{tabular}[c]{#{}c#{}}
$\delta$ \\
7.08$\times 10^{2}$ \\
(1.74$\times 10^{-1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\alpha$ \\
1.07$\times 10^{2}$ \\
(3.24$\times 10^{-1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\beta$ \\
1.14$\times 10^{1}$ \\
(1.14$\times 10^{1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\lambda$ \\
1.84$\times 10^{1}$ \\
(1.89)
\end{tabular} & 32.0 & 40.0 & 40.7 & 48.6 & 0.2639 & 1.4517 & 0.1257 & 0.2727 & 0.1704 \\ \mlrule
TLOBX-L
& \begin{tabular}[c]{#{}c#{}}
$\alpha$ \\
3.17$\times 10^{-1}$ \\
(1.56$\times 10^{-1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\theta$ \\
1.99$\times 10^{1}$ \\
(8.88)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\beta$ \\
9.13$\times 10^{-1}$ \\
(6.17$\times 10^{-2}$)
\end{tabular}
& -- & 42.3 & 48.3 & 48.7 & 54.7 & 0.4676 & 2.5657 & 0.2280 & 0.0029$^{**}$ & 0.6164 \\ \mlrule
TL-L
& \begin{tabular}[c]{#{}c#{}}
$\alpha$ \\
4.22$\times 10^{-1}$ \\
(2.96$\times 10^{-1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\theta$ \\
9.53 \\
(5.85)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\beta$ \\
3.53 \\
(3.85$\times 10^{-1}$)
\end{tabular}
& -- & 62.6 & 68.6 & 69.0 & 75.0 & 0.6755 & 3.6946 & 0.3781 & 0.0001$^{*}$ & 2.4809 \\ \mlrule
MO-L
& \begin{tabular}[c]{#{}c#{}}
$\delta$ \\
2.85$\times 10^{1}$ \\
(1.27$\times 10^{1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\beta$ \\
7.92 \\
(8.73$\times 10^{-1}$)
\end{tabular}
& -- & -- & 45.6 & 49.6 & 49.8 & 53.9 & 0.4969 & 2.7489 & 0.1537 & 0.1019
& 0.3005 \\
\mlrule
OBX-L
& \begin{tabular}[c]{#{}c#{}}
$\theta$ \\
5.83 \\
(7.73$\times 10^{-1}$)
\end{tabular}
& \begin{tabular}[c]{#{}c#{}}
$\beta$ \\
1.03 \\
(6.09$\times 10^{-2}$)
\end{tabular}
& -- & -- & 45.6 & 51.7 & 51.9 & 56.0 & 0.5629 & 3.0915 & 0.2313 & 0.0024$^{**}$ & 0.6509 \\ \midrule[\heavyrulewidth]
\multicolumn{14}{#{}l}{$^{*}$p-value $<0.0001$, \qquad$^{**}$p-value $<0.005$}
\end{tabular}%
\end{sidewaystable}
\end{document}
You could use a (bit) smaller font and place this table on a landscape page:
\documentclass[10pt, twoside]{article}
\usepackage[b5j,hmargin={1 in,0.6 in},vmargin={1 in,0.6 in}]{geometry}
\usepackage{times}
\usepackage[labelsep=space, labelfont=bf]{caption}
\usepackage{amsmath,amssymb,amsthm,latexsym}
\usepackage{lscape}
\begin{document}
\begin{landscape}
\begin{table}[htbp]
\caption{Parameter estimates }
\label{tab:Application_MOTLOBXL1}
\footnotesize
\begin{tabular}{lccccccccccccc}
\hline
Distribution & \multicolumn{4}{c}{Estimates} & -2Log(L) & AIC & AICC & BIC & $W^{*}$ & $A^{*}$ & K-S & P-value & SS \\ \hline
MOTLOBX-L & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 2.62$\times 10^{-3}$\\ (8.33$\times 10^{-4}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 1.21$\times 10^{1}$\\ (2.94$\times 10^{-4}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\delta$\\ 1.06$\times 10^{3}$\\ (1.41$\times 10^{-9}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 1.13\\ (5.42$\times 10^{-2}$)\end{tabular} & 24.4 & 32.4 & 33.1 & 41.0 & 0.0639 & 0.3929 & 0.0891 & 0.6998 & 0.0581 \\ \hline
MOTLOBX-W & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 5.71$\times 10^{-3}$\\ (2.01$\times 10^{-3}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 8.45$\times 10^{1}$\\ (6.09$\times 10^{-6}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\delta$\\ 8.12$\times 10^{2}$\\ (1.28$\times 10^{-8}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\lambda$\\ 3.61$\times 10^{-1}$\\ (2.07$\times 10^{-2}$)\end{tabular} & 25.1 & 33.1 & 33.8 & 41.7 & 0.1076 & 0.6042 & 0.0971 & 0.5928 & 0.0840 \\ \hline
WL & \begin{tabular}[c]{#{}c#{}}$a$\\ 3.29$\times 10^{-1}$\\ (6.38$\times 10^{-2}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$b$\\ 3.97\\ (3.85$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 7.24$\times 10^{3}$\\ (6.30$\times 10^{-5}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 1.41$\times 10^{4}$\\ (3.25$\times 10^{-5}$)\end{tabular} & 29.1 & 37.1 & 37.8 & 45.6 & 0.1962 & 1.0892 & 0.1425 & 0.1544 & 0.1813\\ \hline
GBXII & \begin{tabular}[c]{#{}c#{}}$a$\\ 3.01$\times 10^{-2}$\\ (3.27$\times 10^{-2}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$b$\\ 1.42\\ (5.97$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$c$\\ 1.57\\ (5.42$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 3.22\\ (1.87)\end{tabular} & 28.0 & 36.0 & 36.7 & 44.6 & 0.1616 & 0.9076 & 0.1318 & 0.2240 & 0.1504\\ \hline
MOOBII-Lo & \begin{tabular}[c]{#{}c#{}}$\delta$\\ 4.51$\times 10^{2}$\\ (4.34$\times 10^{-6}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 1.96\\ (1.71$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 9.20$\times 10^{-2}$\\ (4.17$\times 10^{-2}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\lambda$\\ 4.45\\ (7.51$\times 10^{-2}$)\end{tabular} & 40.4 & 48.4 & 49.1 & 57.0 & 0.3724 & 2.0787 & 0.1412 & 0.1619 & 0.2428\\ \hline
MOOBII-L & \begin{tabular}[c]{#{}c#{}}$\delta$\\ 7.08$\times 10^{2}$\\ (1.74$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 1.07$\times 10^{2}$\\ (3.24$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 1.14$\times 10^{1}$\\ (1.14$\times 10^{1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\lambda$\\ 1.84$\times 10^{1}$\\ (1.89)\end{tabular} & 32.0 & 40.0 & 40.7 & 48.6 & 0.2639 & 1.4517 & 0.1257 & 0.2727 & 0.1704\\ \hline
TLOBX-L & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 3.17$\times 10^{-1}$\\ (1.56$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 1.99$\times 10^{1}$\\ (8.88)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 9.13$\times 10^{-1}$\\ (6.17$\times 10^{-2}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}} - \end{tabular} & 42.3 & 48.3 & 48.7 & 54.7 & 0.4676 & 2.5657 & 0.2280 & 0.0029 & 0.6164 \\ \hline
TL-L & \begin{tabular}[c]{#{}c#{}}$\alpha$\\ 4.22$\times 10^{-1}$\\ (2.96$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 9.53\\ (5.85)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 3.53\\ (3.85$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}} - \end{tabular} & 62.6 & 68.6 & 69.0 & 75.0 & 0.6755 & 3.6946 & 0.3781 & $<0.0001$ & 2.4809 \\ \hline
MO-L & \begin{tabular}[c]{#{}c#{}}$\delta$\\ 2.85$\times 10^{1}$\\ (1.27$\times 10^{1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 7.92\\ (8.73$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}-\end{tabular} & \begin{tabular}[c]{#{}c#{}} - \end{tabular} & 45.6 & 49.6 & 49.8 & 53.9 & 0.4969 & 2.7489 & 0.1537 & 0.1019
& 0.3005 \\ \hline
OBX-L & \begin{tabular}[c]{#{}c#{}}$\theta$\\ 5.83\\ (7.73$\times 10^{-1}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}$\beta$\\ 1.03\\ (6.09$\times 10^{-2}$)\end{tabular} & \begin{tabular}[c]{#{}c#{}}-\end{tabular} & \begin{tabular}[c]{#{}c#{}} - \end{tabular} & 45.6 & 51.7 & 51.9 & 56.0 & 0.5629 & 3.0915 & 0.2313 & 0.0024 & 0.6509 \\ \hline
\end{tabular}%
\end{table}
\end{landscape}
\end{document}
I find it a bit difficult to make good looking tables in LaTeX, so I usually use this site: https://www.tablesgenerator.com/.
It lets you create your table and then it spits out the LaTeX code.
I hope you can use it.
I want to create a table like this in Rmarkdown:
and this website can generate codes to create a similar table in LaTeX which can be used in Rmarkdown. However, after generating the code and copying it into Rmarkdown, I received an error:
The code in Rmarkdown:
---
title: "misc"
author: "Me"
date: "`r Sys.Date()`"
output:
pdf_document:
keep_tex: true
extra_dependencies: caption
number_sections: yes
fig_caption: yes
header-includes:
- \PassOptionsToPackage{table,xcdraw}{xcolor}
- \usepackage{xcolor}
- \usepackage{color}
- \usepackage{float}
- \usepackage{framed}
- \usepackage{fontawesome}
- \usepackage{caption}
- \usepackage{multirow}
- \usepackage[table]{xcolor}
fontsize: 11pt
urlcolor: blue
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{=latex}
\begin{table}[]
\begin{tabular}{|
>{\columncolor[HTML]{656565}}c |lcccc|}
\hline
\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} } & \multicolumn{5}{c|}{\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} Type of Distribution}} \\ \cline{2-6}
\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} } & \multicolumn{1}{l|}{} & \multicolumn{1}{l|}{Lognormal} & \multicolumn{1}{l|}{Exponential} & \multicolumn{1}{l|}{Gamma} & \multicolumn{1}{l|}{Weibull} \\ \cline{2-6}
\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} } & \multicolumn{1}{l|}{Box-Cox} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{\cellcolor[HTML]{9B9B9B}\textbf{Y}} & \cellcolor[HTML]{9B9B9B}\textbf{Y} \\ \cline{2-6}
\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} } & \multicolumn{1}{l|}{Exponential} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{Y} & Y \\ \cline{2-6}
\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} } & \multicolumn{1}{l|}{Simple power} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{\cellcolor[HTML]{9B9B9B}\textbf{Y}} & \multicolumn{1}{c|}{\cellcolor[HTML]{9B9B9B}\textbf{Y}} & \cellcolor[HTML]{9B9B9B}\textbf{Y} \\ \cline{2-6}
\multirow{-6}{*}{\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} \begin{tabular}[c]{#{}c#{}}Type of\\ transformation\end{tabular}}} & \multicolumn{1}{l|}{Logarithmic} & \multicolumn{1}{c|}{\cellcolor[HTML]{9B9B9B}\textbf{Y}} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{\cellcolor[HTML]{9B9B9B}\textbf{N}} & \cellcolor[HTML]{9B9B9B}\textbf{N} \\ \hline
\end{tabular}
\end{table}
```
and here the Error I receive:
! Undefined control sequence.
<argument> | >{\columncolor
[HTML]{656565}}c |lcccc|
l.92 >{\columncolor[HTML]{656565}}c |lcccc|}
I also followed the instructions here, but didn't work and when I remove the - \PassOptionsToPackage{table,xcdraw}{xcolor}in the preamble I get this error:! LaTeX Error: Option clash for package xcolor.
The problem is that rmarkdown automatically loads the xcolor package way before it inserts the header-includes, so you don't have a chance to influence the package options there.
As a workaround, you can define table as class option, which will then be passed to all packages, including the xcolor package (and hope for the best that it won't cause any problems in other packages...)
---
title: "misc"
author: "Me"
date: "`r Sys.Date()`"
output:
pdf_document:
keep_tex: true
extra_dependencies: caption
number_sections: yes
fig_caption: yes
classoption: table
header-includes:
- \usepackage{float}
- \usepackage{framed}
- \usepackage{fontawesome}
- \usepackage{caption}
- \usepackage{multirow}
fontsize: 11pt
urlcolor: blue
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{=latex}
\begin{table}[htbp]
\begin{tabular}{|
>{\columncolor[HTML]{656565}}c |lcccc|}
\hline
\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} } & \multicolumn{5}{c|}{\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} Type of Distribution}} \\ \cline{2-6}
\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} } & \multicolumn{1}{l|}{} & \multicolumn{1}{l|}{Lognormal} & \multicolumn{1}{l|}{Exponential} & \multicolumn{1}{l|}{Gamma} & \multicolumn{1}{l|}{Weibull} \\ \cline{2-6}
\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} } & \multicolumn{1}{l|}{Box-Cox} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{\cellcolor[HTML]{9B9B9B}\textbf{Y}} & \cellcolor[HTML]{9B9B9B}\textbf{Y} \\ \cline{2-6}
\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} } & \multicolumn{1}{l|}{Exponential} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{Y} & Y \\ \cline{2-6}
\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} } & \multicolumn{1}{l|}{Simple power} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{\cellcolor[HTML]{9B9B9B}\textbf{Y}} & \multicolumn{1}{c|}{\cellcolor[HTML]{9B9B9B}\textbf{Y}} & \cellcolor[HTML]{9B9B9B}\textbf{Y} \\ \cline{2-6}
\multirow{-6}{*}{\cellcolor[HTML]{656565}{\color[HTML]{FFFFFF} \begin{tabular}[c]{#{}c#{}}Type of\\ transformation\end{tabular}}} & \multicolumn{1}{l|}{Logarithmic} & \multicolumn{1}{c|}{\cellcolor[HTML]{9B9B9B}\textbf{Y}} & \multicolumn{1}{c|}{Y} & \multicolumn{1}{c|}{\cellcolor[HTML]{9B9B9B}\textbf{N}} & \cellcolor[HTML]{9B9B9B}\textbf{N} \\ \hline
\end{tabular}
\end{table}
```
In this table, how can I have the upper line that matches between the two tables? I would like to have two tables with the same height. Here is the code that I used to create the table
\documentclass{article}
\usepackage{geometry}
\usepackage{textcomp}
\usepackage{adjustbox}
\usepackage{mathtools}
\usepackage{booktabs} %
\usepackage[group-separator={,}]{siunitx}
\usepackage{changepage}
\newcommand{\undepth}[1]{%
\smash[b]{%
\begin{varwidth}[t]{\linewidth}#1\end{varwidth}
}%
}
\usepackage{makecell}%To keep spacing of text in tables
\begin{document}
\begin{table}[htbp!]
\centering
\footnotesize
\caption{caption}
\begin{tabular}{lSSSS}
\toprule
\makecell[cc]{column1 \\ second line} & \multicolumn{1}{l}{column2} & \multicolumn{1}{l}{column3} & \multicolumn{1}{l}{column4} & \multicolumn{1}{l}{column5} \\
\midrule
A & 4 & 0 & 0.00 & 4 \\
B & 30 & 0 & 0.00 & 30 \\
\bottomrule
\end{tabular}
\quad
\footnotesize
\begin{tabular}{lSS}
\toprule
& {Column1.1 } & {Column2.1}\\
\midrule
A & 0.02 & 0.00 \\
B & 0.04 & 0.00 \\
\bottomrule
\end{tabular}%
\end{table}%
\end{document}
Quick hack:
Put some invisible dummy header of the same height as in the other table
\documentclass{article}
\usepackage{geometry}
\usepackage{textcomp}
\usepackage{adjustbox}
\usepackage{mathtools}
\usepackage{booktabs} %
\usepackage[group-separator={,}]{siunitx}
\usepackage{changepage}
\newcommand{\undepth}[1]{%
\smash[b]{%
\begin{varwidth}[t]{\linewidth}#1\end{varwidth}
}%
}
\usepackage{makecell}%To keep spacing of text in tables
\begin{document}
\begin{table}[htbp!]
\centering
\footnotesize
\caption{caption}
\begin{tabular}{lSSSS}
\toprule
\makecell[cc]{column1 \\ second line} & \multicolumn{1}{l}{column2} & \multicolumn{1}{l}{column3} & \multicolumn{1}{l}{column4} & \multicolumn{1}{l}{column5} \\
\midrule
A & 4 & 0 & 0.00 & 4 \\
B & 30 & 0 & 0.00 & 30 \\
\bottomrule
\end{tabular}
\quad
\footnotesize
\begin{tabular}{lSS}
\toprule
\makecell[cc]{\mbox{} \\ \mbox{}} & {Column1.1 } & {Column2.1}\\
\midrule
A & 0.02 & 0.00 \\
B & 0.04 & 0.00 \\
\bottomrule
\end{tabular}%
\end{table}%
\end{document}
Cleaner solution:
Use only one tabular
\documentclass{article}
\usepackage{geometry}
\usepackage{textcomp}
\usepackage{adjustbox}
\usepackage{mathtools}
\usepackage{booktabs} %
\usepackage[group-separator={,}]{siunitx}
\usepackage{changepage}
\newcommand{\undepth}[1]{%
\smash[b]{%
\begin{varwidth}[t]{\linewidth}#1\end{varwidth}
}%
}
\usepackage{makecell}%To keep spacing of text in tables
\begin{document}
\begin{table}[htbp!]
\centering
\footnotesize
\caption{caption}
\begin{tabular}{lSSSSSS}
\cmidrule[\heavyrulewidth](r){1-5}\cmidrule[\heavyrulewidth](l){6-7}
\makecell[cc]{column1 \\ second line} & \multicolumn{1}{l}{column2} & \multicolumn{1}{l}{column3} & \multicolumn{1}{l}{column4} & \multicolumn{1}{l}{column5} & {Column1.1 } & {Column2.1} \\
\cmidrule(r){1-5}\cmidrule(l){6-7}
A & 4 & 0 & 0.00 & 4 & 0.02 & 0.00 \\
B & 30 & 0 & 0.00 & 30 & 0.04 & 0.00 \\
\cmidrule[\heavyrulewidth](r){1-5}\cmidrule[\heavyrulewidth](l){6-7}
\end{tabular}%
\end{table}%
\end{document}
\centering
\[
\begin{matrix}
\hline P& \beta^{1p} &\beta^{2p} & \beta^{3p} & \beta^{4p} &E(c^{p}) &\sigma(\delta c^{p}) &E(r^{p}-r^{f}) & \sigma( r^{p}-r^{f}) \\
\hline 1& 1.4360 & 0.0018& -0.0123 &-0.0195 &0.0292 & 0.0048 &0.0013 &0.0809 \\
5& 1.1428 & 0.0007 &-0.0098 &-0.0091 & 0.0113 &0.0018 &0.0041 &0.0618 \\
10& 1.0108 & 0.0005 & -0.0083 & -0.0073 & 0.0086 &0.0013 &0.0042 &0.0544 \\
15& 0.9065 &0.0004 &-0.0080 &-0.0061 & 0.0068 & 0.0010 &0.0050 &0.0493 \\
20&0.7602 &0.0003 &-0.0065 & -0.0045 & 0.0050 &0.0008 & 0.0060 & 0.0417\\
25& 0.7192 & 0.0000 &-0.0061 & -0.0010 & 0.0020 & 0.0003 & 0.0068 &0.0417
\end{matrix}
\]
This is my code and I want this matrix to be more in center.
The following code has a problem with the second \newsavebox{\spec}. It does not compile. However if I use twice the \speciesone, i.e.:
\matrix [matrix of nodes] {
\node (species1) [shape=rectangle,draw] {\usebox{\speciesone}}; & \node (species2) [shape=rectangle,draw] {\usebox{\speciesone}};\\
};
I have no problem.
\documentclass[xcolor=pdftex,table,10pt,yellow,mathserif]{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\newsavebox{\speciesone}
\sbox{\speciesone}{
\begin{tabular}{c c c c}
\multicolumn{3}{c}{{$k~ \times $ 1}} \tabularnewline
\hline
$\vec{v} =$ & $v_{1}$ & $v_{2}$ & $v_{3}$ \tabularnewline
\hline
\hline
& $\circ$ & $\circ$ & $\circ$ \tabularnewline
\end{tabular}
}
\newsavebox{\spec}
\sbox{\spec}{
\begin{tabular}{c c c c}
\multicolumn{3}{c}{{$k~ \times $ 2}} \tabularnewline
\hline
$\vec{v} =$ & $v_{1}$ & $v_{2}$ & $v_{3}$ \tabularnewline
& $\circ$ & $\circ$ & $\circ$ \tabularnewline
\end{tabular}
}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of nodes] {
\node (species1) [shape=rectangle,draw] {\usebox{\speciesone}}; & \node (species2) [shape=rectangle,draw] {\usebox{\spec}};\\
};
\end{tikzpicture}
\end{document}
To avoid Undefined control sequence... errors, you should cut \begin{document} and paste it before both
\newsavebox{\speciesone}
\sbox{\speciesone}{
...
}
and
\newsavebox{\spec}
\sbox{\spec}{
...
}