I want to do a diagram following the idea of How to create fixed width table columns with text raggedright/centered/raggedleft?. Using the code
\documentclass{article}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\begin{tabular}{| C{2cm} | C{2cm} | C{2cm} | C{2cm} | C{2cm} | C{2cm} |}
\hline
$f(x)$ & \multicolumn{5}{c|}{+}\\
\hline
$f'(x)$ & \multicolumn{2}{c|}{+} & \multicolumn{2}{c|}{-} & +\\
\hline
$f''(x)$ & - & \multicolumn{2}{c|}{-} & \multicolumn{2}{c|}{+}\\
\hline
\end{tabular}
\end{document}
the widths are ignored:
But adding a multicolumn-less row:
\documentclass{article}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\begin{table}[h]
\begin{tabular}{| C{2cm} | C{2cm} | C{2cm} | C{2cm} | C{2cm} | C{2cm} |}
\hline
$f(x)$ & \multicolumn{5}{c|}{+}\\
\hline
$f'(x)$ & \multicolumn{2}{c|}{+} & \multicolumn{2}{c|}{-} & +\\
\hline
$f''(x)$ & + & \multicolumn{2}{c|}{-} & \multicolumn{2}{c|}{+}\\
\hline
U & V & W & X & Y & Z\\
\hline
\end{tabular}
\end{table}
\end{document}
the widths are OK:
What I'm missing?
C
on its own as you have defined it to take an argument, butC{\dimexpr4cm+2\tabcolsep+\arrayrulewidth}
would make a column the width of a two column span