Menu

#338 ConTeXt and ampersand

v1.0 (example)
closed-wont-fix
nobody
None
5
2018-12-27
2014-10-30
No

Bug #246, concerning the ampersand catcode in ConTeXt MKIV is not solved. Try compiling the following with the command context:

\usemodule[tikz]
\usetikzlibrary[matrix]
\starttext
\starttikzpicture
  \node[matrix of nodes]{A&B\\C&D\\};
\stoptikzpicture

\starttikzpicture
  \node[matrix of math nodes]{A&B\\C&D\\};
\stoptikzpicture
\stoptext

You will notice that the matrix of nodes works fine, but the matrix of math nodes gives an error.

The reason we get an error is that, when entering math mode, & is made active and assinged a macro containg an & with catcode 4. To see this, you can do a \showthe\everymathematics: you will see \let &\normalmathaligntab somewhere in there. This overwrites tikz's definition of & as \pgfmatrixnextcell.

It looks like ConTeXt tabulars use the commands \NC and \NR instead of & and \\ for next column/next row, so it might make sense to make these comands shorthands for \pgfmatrixnextcell and \pgfmatrixendrow (cf. http://wiki.contextgarden.net/Table)

Discussion

  • Henri Menke

    Henri Menke - 2018-12-26

    Use ampersand replacement.

    \usemodule[tikz]
    \usetikzlibrary[matrix]
    \starttext
    \starttikzpicture
      \node[matrix of nodes]{A&B\\C&D\\};
    \stoptikzpicture
    
    \starttikzpicture
      \node[matrix of math nodes,ampersand replacement=\&]{A\&B\\C\&D\\};
    \stoptikzpicture
    \stoptext
    

    Mark as wont-fix.

     
  • Stefan Pinnow

    Stefan Pinnow - 2018-12-27
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -Bug #246, concerning the ampersand catcode in ConTeXt MKIV is not solved.  Try compiling the following with the command `context`:
    +[Bug #246](https://sourceforge.net/p/pgf/bugs/246/), concerning the ampersand catcode in ConTeXt MKIV is not solved.  Try compiling the following with the command `context`:
    
     ~~~~~
     \usemodule[tikz]
    @@ -16,6 +16,6 @@
    
     You will notice that the `matrix of nodes` works fine, but the `matrix of math nodes` gives an error.
    
    -The reason we get an error is that, when entering math mode, & is made active and assinged a macro containg an & with catcode 4.  To see this, you can do a \showthe\everymathematics: you will see \let &\normalmathaligntab somewhere in there.  This overwrites tikz's definition of & as \pgfmatrixnextcell.
    +The reason we get an error is that, when entering math mode, `&`  is made active and assinged a macro containg an `&` with catcode 4.  To see this, you can do a `\showthe\everymathematics`: you will see `\let &\normalmathaligntab` somewhere in there.  This overwrites tikz's definition of `&` as `\pgfmatrixnextcell`.
    
    -It looks like ConTeXt tabulars use the commands \NC and \NR instead of & and \\ for next column/next row, so it might make sense to make these comands shorthands for \pgfmatrixnextcell and \pgfmatrixendrow (cf. http://wiki.contextgarden.net/Table)
    +It looks like ConTeXt tabulars use the commands `\NC` and `\NR` instead of `&` and `\\` for next column/next row, so it might make sense to make these comands shorthands for `\pgfmatrixnextcell` and `\pgfmatrixendrow` (cf. http://wiki.contextgarden.net/Table)
    
    • status: open --> closed-wont-fix
     
MongoDB Logo MongoDB