Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support & in matrices without catcode change #1081

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Commits on Dec 18, 2021

  1. Fix "\matrix{a \\ b &[between origins] c};"

    Column separation is handled by modifying the bounding box of cells.
    Adjust this to handle the case when [between origins] is specified
    in later rows, like
    
    \begin{tikzpicture}
      \matrix[column sep={5mm,between origins}, nodes=draw]{
        \node{1}; & \node(2){2}; \\
        \node{3}; & \node{4}; & \node(5){5}; \\
      };
      \draw (5) -- (2);
    \end{tikzpicture}
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    2407ff0 View commit details
    Browse the repository at this point in the history
  2. Break up \pgf@matrix@endcell for future changes.

    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    85f842a View commit details
    Browse the repository at this point in the history
  3. pgfmatrix: Smuggle row and column separation out of all cells.

    Upcoming changes require that \pgfmatrixendrow start with &,
    and column separation will need to be saved as well,
    as it will be processed later outside the cell group.
    
    These are to support constructs like (see bug pgf-tikz#503)
    
    \matrix[every odd row/.style={row sep=1cm}] {...};
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    3418205 View commit details
    Browse the repository at this point in the history
  4. pgfmatrix: delay handling column separation.

    This is a step towards supporting & in place of \pgfmatrixnextcell,
    as & is not able to immediately process any argument.
    
    Move code from \pgf@matrix@endcell to \pgfmatrixnextcell.
    Remove \pgf@matrix@process@nextcell@options, no longer used.
    
    Notable aspects of the move needing care:
    1) The test \ifpgf@matrix@last@cell@in@row has been omitted,
       as no longer necessary, and no longer guaranteed to be correct.
    2) The test \pgfmatrixcurrentcolumn < \pgf@matrix@numberofcolumns
       still yields the correct result, even though
       \pgf@matrix@numberofcolumns might have a different value.
    3) \pgf@matrix@maxx might have a different value, but needs no change
       in code.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    70a400a View commit details
    Browse the repository at this point in the history
  5. Remove \ifpgf@matrix@last@cell@in@row.

    Last commit made it a noop code.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    11f8ab9 View commit details
    Browse the repository at this point in the history
  6. Remove one \pgf@matrix@maxxN initialization, no longer needed.

    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    a7ab036 View commit details
    Browse the repository at this point in the history
  7. pgfmatrix: remove unused \pgf@matrix@eom@found.

    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    739b4a5 View commit details
    Browse the repository at this point in the history
  8. Simplify detecting empty cell.

    Detect it by the single token \pgf@matrix@endcell
    (brought in by & starting a new cell), which is easier to check than
    the two tokens \let\pgf@matrix@signal@cell@end.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    59fe51c View commit details
    Browse the repository at this point in the history
  9. pgfmatrix: Care for & when parsing optional arguments.

    Think of "\pgfmatrixnextcell &" or "\pgfmatrixendrow &".
    
    The usual trick for this is surround looking ahead of next character
    by "\ifnum\iffalse{\fi0=`}\fi" and "\ifnum`{=0}\fi",
    but here we use variants.
    
    \pgfmatrixnextcell:
      As the look ahead does not occur in math mode, do it in a TeX group.
      This defends again & or \cr ending up in a (hidden) temporary
      control sequence for a long time.
    
    \pgfmatrixendrow:
      Look for an optional argument in the \noalign group, where the trick
      is not necessary.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    3c127e2 View commit details
    Browse the repository at this point in the history
  10. Remove a no longer needed global assignment.

    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    b4c3b7c View commit details
    Browse the repository at this point in the history
  11. pgfmatrix: support & as cell separator, simplify last cell test.

    There is no longer an ampersand "wrong catcode".
    
    In documentation promote & as cell separator, use it in all examples,
    and remove limitation due to catcode of ampersand.
    Still document \pgfmatrixnextcell, which is now simply &.
    
    The main technical idea is adding "\aftergroup\pgf@matrix@nextcell"
    to the \halign preamble.  The macro \pgf@matrix@nextcell will be added
    after the cell group, i.e., right after "&" in user input, so TeX will
    see \pgf@matrix@nextcell as the first token of the next table cell.
    Now \pgf@matrix@nextcell does what \pgfmatricnextcell did before.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    ef27e67 View commit details
    Browse the repository at this point in the history
  12. No longer make & active in TikZ matrices.

    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    9181d20 View commit details
    Browse the repository at this point in the history
  13. pgfmatrix: Remove internal variable \pgf@matrix@paddingskip.

    Use \pgf@matrix@maxxCOLUMN instead, which might have a different value
    but doesn't need extra global assignments.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    d660a5a View commit details
    Browse the repository at this point in the history
  14. pgfmatrix: Simplify by removing \ifpgf@matrix@empty@cell.

    Temporarily redefine \pgfmatrixendcode in empty cells, which is a
    much simpler way to omit end code.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    d4ebe22 View commit details
    Browse the repository at this point in the history
  15. Recombine \pgf@matrix@endcell.

    Since one part is extremely short.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    ab2bedf View commit details
    Browse the repository at this point in the history
  16. \pgfmatrix: deduplicate halign header.

    This is to simplify code without changing functionality.
    Move \pgfmatrix@init@row out of halign header to this end.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    2a365ea View commit details
    Browse the repository at this point in the history
  17. \pgfmatrix: slightly simplify adding row separation.

    Make less dimension calculations, glue insertions, assignments
    for the same result.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    aea0349 View commit details
    Browse the repository at this point in the history
  18. \pgfmatrix: Optimize out \pgf@matrix@column@sep@N.

    Simplify code to handle column separation in pgf matrices:
    change \pgf@picminx only once per matrix cell for this purpose.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    fbcaa39 View commit details
    Browse the repository at this point in the history
  19. matrices: Add some tests for & as cell separator.

    Include tests for packages: tikz-cd, tikz-dependency, beamer
    (deliberately ignoring advice to not use & as cell separator).
    
    Omit dvisvgm result for beamer: it contains complicated dvips specials.
    
    Signed-off-by: Gábor Braun <gabor.braun@uni-duisburg-essen.de>
    gabor-braun committed Dec 18, 2021
    Configuration menu
    Copy the full SHA
    10a77b1 View commit details
    Browse the repository at this point in the history