You may be over-thinking the issue of how to typeset the string that spans the two header cells, especially as the string that needs to be typeset is fairly short. Instead of fiddling with the \mcx
macro, I would use a simple \multicolumn{2}{c}{...}
directive to typeset the string in question. (Yes, that's all it takes!)
To provide more visual structure to the header, I'd also provide a \cmidrule(l){4-5}
directive.

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs,tabularx,float}
\usepackage[add-decimal-zero = true,
add-integer-zero = true,
round-integer-to-decimal,
round-mode = places,
round-precision=1]{siunitx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand{\mcone}[1]{\multicolumn{1}{C}{#1}}
\begin{document}
\begin{table}
\caption{Prevalence of Undernourishment estimated for India with
different parameter estimates} \label{orgc39fb42}
\begin{tabularx}{\textwidth}{ l
S[table-format=1.3,round-precision=3]
S[table-format=1.3,round-precision=3]
S[table-format=2,round-precision=0]
S[table-format=2,round-precision=0]}
\toprule
Mean & \mcone{CV} & \mcone{Skew} &
\multicolumn{2}{c}{Prev of Unment and met} \\
\cmidrule(l){4-5} % <--- new
& & & \mcone{MPEX=1791} & \mcone{MPEX=2037}\\
\midrule
2455 & 0.25 & 0.55 & 15 & 23\\
2455 & 0.294 & 0.528 & 18 & 26\\
2135 & 0.294 & 0.528 & 27 & 39\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
Addendum: The preceding approach works because the string that's being typeset is relatively short -- specifically, it is less wide than 2 basic C
columns. If you have another table with a longer string, or if the string needs to span 3 (or more!) columns, you may want to redefine your \mcx
macro as follows:
\newcommand{\mcx}[2]{\multicolumn{#1}%
{>{\hsize=\dimexpr #1\hsize +\numexpr2*#1-2\relax\tabcolsep \relax}C}%
{#2}}
and then typeset the string as \mcx{2}{Prev of Unment and met}
. (You may verify for yourself that the solutions generated by \mcx{2}{Prev of Unment and met}
and \multicolumn{2}{c}{Prev of Unment and met}
are identical.)
How (why) does this revised form of \mcx
work? Suppose there are n
columns to be spanned by the string that may be longer than the n
columns (and may therefore require automatic line wrapping). The usable width of each underlying C
column is \hsize
, and its total width (including the whitespace padding on either side) is \hsize+2\tabcolsep
. The total width of the n
columns of type C
is therefore n\hsize+2n\tabcolsep
. Since the total width of the combined column should be equal to this length, the usable width of the combined columns is n\hsize+2(n-1)\tabcolsep
. Expressing this calculation in TeX syntax produces
\hsize=\dimexpr #1\hsize +\numexpr2*#1-2\relax\tabcolsep \relax
and that's what's given as the "prefix" to C
in the definition of \mxc
. (Do verify for yourself that \numexpr2*#1-2\relax\tabcolsep
evaluates to 2(n-1)
.)
\multicolumn{2}{c}{Prev of Unment and met}
inseat of themcx
you have