You have to specify \hsize
like |>{\hsize=2\hsize}X|
. If it is for three columns 3\hsize
and so on. To be precise, take the \tabcolsep
and one \arrayrulewidth
in to account like
>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax}
Code:
\documentclass[12pt]{article}
\usepackage{tabularx,lipsum}
\usepackage[table]{xcolor}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{|X|X|}
\hline
\multicolumn{2}{|>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax}X|}{\sffamily Lorem ipsum dolor sit amet, }\\\hline
\rowcolor{blue!40}
\multicolumn{2}{|>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax}X|}{\lipsum*[2]}\\\hline
\sffamily Lorem av:&\sffamily Ipsum:\\
foo&bar \\\hline
\end{tabularx}
\end{document}
As an example, for three columns you have to use
>{\hsize=\dimexpr3\hsize+4\tabcolsep+2\arrayrulewidth\relax}
as in
\documentclass[12pt]{article}
\usepackage{tabularx,lipsum}
\usepackage[table]{xcolor}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{|X|X|X|}
\hline
\multicolumn{3}{|>{\hsize=\dimexpr3\hsize+4\tabcolsep+2\arrayrulewidth\relax}X|}{\sffamily Lorem ipsum dolor sit amet, }\\\hline
\rowcolor{blue!40}
\multicolumn{3}{|>{\hsize=\dimexpr3\hsize+4\tabcolsep+2\arrayrulewidth\relax}X|}{\lipsum*[2]}\\\hline
\sffamily Lorem av:&\sffamily Ipsum:&\sffamily Ipsum:\\
foo&bar &bar\\\hline
\end{tabularx}
\end{document}
Here there are three columns, six \tabcolsep
s and 4 \arrayrulewidth
s. Of these 2 outer \tabcolsep
s and 2 outer \arrayrulewidth
s are retained (inside multi column) while the space for 4 \tabcolsep
s and 2 \arrayrulewidth
s have to be used.