In my table
, in order to have texts centered in each cell, I am using
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
and instead of a simple p{1.5cm}
, I am using
>{\centering\arraybackslash}p{1.5cm}
I am also using \toprule
, \midrule
, and \bottomrule
along with \usepackage{booktabs}
.
My code is the following:
\documentclass[12pt]{article}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{| >{\centering\arraybackslash}p{1.5cm} | >{\centering\arraybackslash}p{1.2cm} | >{\centering\arraybackslash}p{1.2cm} | >{\centering\arraybackslash}p{1.2cm} | >{\centering\arraybackslash}p{1.2cm} |>{\centering\arraybackslash}p{1.2cm} | >{\centering\arraybackslash}p{1.2cm} | >{\centering\arraybackslash}p{1.2cm} | >{\centering\arraybackslash}p{1.2cm}|}
\toprule
\multirow{2}{*}{} & \multicolumn{4}{c|}{Payoffs} & \multicolumn{4}{c}{ROR} \\
\cline{2-9}
& $\theta =1$ & $\theta =2$ & $E(P)$ & $\sigma(P)$ & $\theta =1$ & $\theta =2$ & $E(r)$ & $\sigma(r)$ \\
\midrule
Asset 1 & 110 & 95 & & & & & & \\
Asset 2 & 105 & 90 & & & & & & \\
Asset 3 & 120 & 90 & & & & & & \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
And my result looks very strange like this:
First, the far right vertical line is short; the first row is not closed on the right.
Second, all the vertical lines are cut.
Any thoughts?
Best Answer
The vertical rule on the right is not short, it's missing, because you've used
instead of
However, instead of adding the vertical rules, follow the guidelines suggested by
booktabs
(since you're using it anyway):The columnar stacking of values promotes visual alignment making the use of vertical rules somewhat obsolete.