pgf icon indicating copy to clipboard operation
pgf copied to clipboard

Support & in matrices without catcode change

Open gabor-braun opened this issue 3 years ago • 7 comments

  1. Support & with its usual catcode as cell separator in matrices, and no longer change the catcode in TikZ
  2. Correctly handle column spacing between origins between columns not specified in the first row.
  3. Simplify some code in pgfmodulematrix.code.tex, most notably that of empty cells.

The documentation has been adjusted to not promote anything else as & as cell separator. All examples now use &, except for style /tikz/ampersand replacment. The macro \pgfmatrixnextcell is still documented.

Two examples have been slightly altered to showcase that between origins work between columns not specified in the first row.

Motivation for this change

Supporting & gets rid of the documented problems when matrices appear at less common places or have content with &.

The optional argument of & is not available immediately, so the code for column spacing needs changing anyway. It was easier not to reproduce an undocumented, unexpected behavior. For explicitness, this change occurs early in the branch.

Simplification are mostly taking the opportunity, and not necessary for the changes above, and appear near end of the branch. Empty cell handling needed change anyway to work correctly for empy cells ending with &.

Testing performed

The commits have been tested with som TikZ pictures, mostly from the documentation. With the last commit the LuaTeX version of the PGF documentation compiles succesfully. It has not been built for intermediate versions.

Checklist

  • [x] Code changes are licensed under GPLv2 + LPPLv1.3c
  • [x] Documentation changes are licensed under FDLv1.2

gabor-braun avatar Dec 02 '21 12:12 gabor-braun

This is an interesting proposal but it needs very careful testing because there are a lot of downstream consumers of this code like tikz-cd.

Please also sign-off on your commits. It can be done in batch using

git remote update
git rebase --exec 'git commit --amend --no-edit -n -s' @{upstream}

hmenke avatar Dec 02 '21 14:12 hmenke

All commits should be signed off now. (Done with git rebase --signoff.)

The manual of tikz-cd version 0.9f successfully compiles under lualatex and xelatex with these changes. (I couldn't compile it with pdflatex even with the upstream version of pgf.)

I understand that lot more testing is necessary.

gabor-braun avatar Dec 03 '21 17:12 gabor-braun

I have added some tests. On my machine they run successfully, but some fail on GitHub. How to access the directory build/test on GitHub, where l3build puts test results?

gabor-braun avatar Dec 18 '21 22:12 gabor-braun

I have added some tests. On my machine they run successfully, but some fail on GitHub. How to access the directory build/test on GitHub, where l3build puts test results?

I've opened PR #1114 to upload *.diff files as an artifact. Before it's merged (and your branch matrix-ampersand rebased), you can download the zipped *.diff files from https://github.com/muzimuzhi/pgf/actions/runs/1597478038.

From the content of *.diff files,

  • some simple lines might come from different latex2e versions
  • dvips output seems OS specific
  • dvisvgm generates rather different output which I can't even guess why

muzimuzhi avatar Dec 19 '21 02:12 muzimuzhi

Thank you for the diffs, they have helped.

For dvisvgm, the font numbers differ, e.g., \FONT24 vs \FONT16. If these are LuaTeX's \fontid, then they are not supposed to be stable. dvisvgm is the only engine using LuaTeX with dvi output. At least I see such entries with the command line

lualatex --output-format=dvi '\documentclass{article}\showoutput \begin{document} abc \end{document}'

Other egines seem to print TeX names instead: \OT1/cmr/m/n/10 and similar.

gabor-braun avatar Dec 20 '21 14:12 gabor-braun

This PR is blocked by #1116.

hmenke avatar Feb 01 '22 11:02 hmenke

Sorry, I had already reviewed this a year ago, but forgot to hit send.

hmenke avatar Oct 23 '23 07:10 hmenke