For typing of quantities of solving mathematical problems I would like to type signs charts (diagrams to visualize the values of expressions). Something like this:

x-5       -    |    -    |    +
x+4       -    |    +    |    +
          +   -4    -    5    +

(@ means full circle). Primarily seeking solutions in ConTeXt, but for inspiration welcome and solutions in Plain or LaTeX. Maybe someone has something similar to what would suit my needs? I do not want to insert a picture, I am rather interested in solutions in a tables.

Thanx Jaroslav


3 Answers 3


I suggest the macro \sgchart which generates desired table. The usage is:

\sgchart {list of points} {formula: signs, formula: signs, formula: signs etc}

for example

\sgchart {-4, ~5} {x-5: --+, x+4: -++, (x+4)/(x-5): +-+}

If the point value isn't preceded by ~ then it is printed with solid bullet (default) and if the ~ precedes then circle is printed. The number of points and the number of formulas are unlimited.

The macro works in plain TeX (and in LaTeX too, because the basic plain TeX syntax is used in this macro). ConTeXt sets catcode of the & to 12 and this brings a little problem. We need to set this catcode to 4 in the area where the macros are defined. This is the reason why there are two lines with \ecatcode macro here. When these lines are used then the macro works in ConTeXt too.

\newdimen\tcolw \tcolw=2.5em % the column width
\def\sgchartA#1:#2,{\cr\ifx,#1,\else $#1$&\sgchartB#2{}\expandafter\sgchartA\fi}
\def\sgchartB#1{\hbox to\tcolw{\hss$#1$\hss}\sgchartC}
   \strut\vrule\kern-.4pt\hbox to\tcolw{\hss$#1$\hss}\expandafter\sgchartC\fi}
\def\sgchartD#1#2,{\ifx\relax#1\else\hbox to\tcolw{\hss$#1#2$\hss}\expandafter\sgchartD\fi}
    \ifx~#1\sgchartS\tcolw\circ \else\sgchartS\tcolw\bullet\fi \expandafter\sgchartE\fi}
\def\sgchartR{\leaders\vrule height2.8pt depth-2.4pt\hfil}
\def\sgchartS#1#2{\hbox to#1{\kern-.2pt\sgchartR \ifx\relax#2\else

\sgchart{-4, ~5} {x-5: --+, x+4: -++, (x+4)/(x-5): +-+}



  • Does anybody know why ConTeXt sets catcode of & to 12? This means that it is incompatible with plain TeX.
    – wipet
    Feb 27, 2015 at 13:56
  • 2
    My thoughts on why changing the catcode of & is a good idea.
    – Aditya
    Feb 28, 2015 at 17:56
  • I asked for it in ConTeXt mailing list. The answer is that context table mechanisms don't use & (and never used it) so there is no reason to make & special. The _ and ^ are also normal characters. For now developers keep the $ for math (and in math mode the & ^ _ work as expected). Mar 1, 2015 at 6:30

Is this enough?

x-5     -   |   -   |   +
x+4     -   |   +   |   +
        +  -4   -   5   +

If not you could use the (mathematical) array environment.

  • O,sorry, there should be some linebreakes in the code.
    – ruediger
    Feb 26, 2015 at 14:47
  • 1
    You have to leave a blank line before the code. If you select the code parts and click the {} icon, the blank line is automatically supplied and the code is properly indented by four spaces (hitting Control-K does the same).
    – egreg
    Feb 26, 2015 at 14:50

Plain TeX (requires e-TeX, though):

  height \dimexpr\fontdimen22\textfont2+0.2pt\relax
  depth -\dimexpr\fontdimen22\textfont2-0.2pt\relax



enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .