[Tex/LaTex] How to create a mathematical sign chart

chartsmath-mode

I've done some Googling and haven't found any way to create the below image in latex:

enter image description here

The derivative isn't important; it's the line with the +, 0 below it including the -1 and 2.

Any ideas how to do this?

Best Answer

Here's an approach using a plain TeX alignment and cleaders...

enter image description here

\documentclass{article}
\begin{document}
\[
\tabskip0pt\openup 3pt
\vbox{\halign{#&&\hbox to 1.2in{\cleaders\hbox{#}\hfill}&\hbox to 0pt{\hss$#$\hss}\cr
&\multispan6 \hfil $f(x) = 6(x-2)(x+1)$ \hfil \cr
\noalign{\medskip}
$f'(x)$ & + & 0 & $ - $ & 0 & + \cr
&---&\vert&---&\vert&---&\cr
&&-1&&2\cr}}
\]
\end{document}
Related Question