In a previous question (How to force type X
columns to wrap their contents when using \multicolumn
command?), I asked for a code that allows me to use \multicolumn
command that crosses type X
columns. Zarko provided me with a code that solves the my issue
multicolumn{3}{>{\hsize=\dimexpr3\hsize+4\tabcolsep\relax}C}{%
Time Needed With Our Approach \newline
(Extended Brown's Method)}
Inspired by his answer, I wrote a custom command as follows
\newcommand{\multcolhsize}[1]{\dimexpr #1\hsize + #1\tabcolsep + \tabcolsep \relax}
Which allows for the concise application of the original code provided by Zarko
\multicolumn{n}{>{\hsize=\multcolhsize{n}\}X}{<text>}
However, right now, when using the code, it does not seem that the text is not properly justified when using \justifying\arraybackslash
in the preamble of type X
columns. Similarly, it does not seem to go exactly to the center when using \centering\arraybackslash
Clearly, the custom command might be improved further to guarantee that it goes exactly to the center or justifies properly for the specified columns.
\documentclass{book}
\usepackage[a4paper]{geometry}
\geometry{twoside=true, showframe=false}
% Horizontal
\geometry{inner=10mm, outer=10mm, includemp=true, bindingoffset=5mm, marginparsep=3.5mm, marginparwidth=15mm}
% Vertical
\geometry{top=20mm, vmarginratio=3:5, includehead=true, includefoot=true, headheight=8pt, headsep=14pt, footskip=5mm}
\usepackage{ragged2e}
\usepackage{tabularx}
\def \tabularxcolumn#1{m{#1}}
\newcolumntype{C}{>{\arraybackslash\Centering}X}
\newcommand{\multcolhsize}[1]{\dimexpr #1\hsize + #1\tabcolsep + \tabcolsep \relax}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{adjustbox}
\begin{document}
\begin{table*}[htp]
\def \tabularxcolumn#1{p{#1}}
\caption{Caption}
\centering
\begin{tabularx}{\textwidth}{r p{3cm} *{10}{C}}
\toprule
&
&
\multicolumn{10}{>{\hsize=\multcolhsize{10}\centering\arraybackslash}X}{Complexity}
\\
\cmidrule(l){3-12}
&
Description &
\adjustbox{rotate=90}{Method 1} &
\adjustbox{rotate=90}{Method 2} &
\adjustbox{rotate=90}{Method 3} &
\adjustbox{rotate=90}{Method 4} &
\adjustbox{rotate=90}{Method 5} &
\adjustbox{rotate=90}{Method 6} &
\adjustbox{rotate=90}{Method 7} &
\adjustbox{rotate=90}{Method 8} &
\adjustbox{rotate=90}{Method 9} &
\adjustbox{rotate=90}{Method 10}
\\
\cmidrule(r){2-2} \cmidrule(l){3-12}
1. &
Description A &
VS &
S &
VS &
S &
VS &
S &
C &
VC &
C &
VC
\\
\addlinespace[0.1cm]
2. &
Description B &
S &
C &
S &
C &
S &
C &
S &
C &
S &
C
\\
\addlinespace[0.1cm]
3. &
Description C &
N &
N &
N &
N &
N &
N &
Y &
VC &
Y &
VC
\\
\addlinespace[0.1cm]
\bottomrule
\end{tabularx}
\end{table*}
\end{document}