TikZ matrix, why doesn't “every even row” work with “row sep” option?












13















Please consider the following mwe:



documentclass[tikz, margin=3mm]{standalone}
usetikzlibrary{matrix}

begin{document}
begin{tikzpicture}
matrix (m) [matrix of math nodes,
nodes={draw, font=footnotesize, minimum size=1em,
anchor=center,inner sep=0pt},
column sep=-pgflinewidth,
row sep=-pgflinewidth,
every even column/.style={column sep=2pt},
every even row/.style={row sep=2pt},% doesn't insert row separation
inner sep=1pt,
left delimiter={[},right delimiter={]},
]
{
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
};
end{tikzpicture}
end{document}


However every even column/.style={column sep=2pt}, yields the expected result, say, introducing additional column separation after each second column, the every even row/.style={row sep=2pt}, doesn't. Did I do something wrong or this is a bug in TikZ v3.1 (I've never tested this before, so I don't know if the same thing happens in v3.0.1)?



enter image description here



edit:



The same thing happens with, for example,



row 2/.style = {row sep=2pt} 


thus it might mean that every even row/.style=... and row <row number> work fine only if one wants to change some properties of cells inside row, for example, the color of nodes borders:



every even row/.style={draw red},


but not if one aims to change row separation (see @AndréC's comment below). However it is interesting, that this is possible to do in every column sep ...



Of course, the (temporary) workaround terminates each second row of the matrix with for example [2pt], but this is annoying when the matrix is huge like here.










share|improve this question

























  • If you write every even row/.style={blue} it works. Then ...

    – AndréC
    Jan 13 at 14:03











  • @AndréC, it cover each second row with blue color. i expected that after each even row will be row separation 2pt as it is at columns.

    – Zarko
    Jan 13 at 14:11











  • Yes, I know, my example suggests that the error may not be in the style, but in another place. Otherwise, the style would not work for the blue color either.

    – AndréC
    Jan 13 at 14:12






  • 1





    The row sep option does not work with keys either row <number>, row <column number> column <column number>, every odd row

    – AndréC
    Jan 13 at 16:07








  • 1





    @AndréC, ones for nodes, ones for matrix as whole. but might be wrong.

    – Zarko
    Jan 13 at 18:18
















13















Please consider the following mwe:



documentclass[tikz, margin=3mm]{standalone}
usetikzlibrary{matrix}

begin{document}
begin{tikzpicture}
matrix (m) [matrix of math nodes,
nodes={draw, font=footnotesize, minimum size=1em,
anchor=center,inner sep=0pt},
column sep=-pgflinewidth,
row sep=-pgflinewidth,
every even column/.style={column sep=2pt},
every even row/.style={row sep=2pt},% doesn't insert row separation
inner sep=1pt,
left delimiter={[},right delimiter={]},
]
{
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
};
end{tikzpicture}
end{document}


However every even column/.style={column sep=2pt}, yields the expected result, say, introducing additional column separation after each second column, the every even row/.style={row sep=2pt}, doesn't. Did I do something wrong or this is a bug in TikZ v3.1 (I've never tested this before, so I don't know if the same thing happens in v3.0.1)?



enter image description here



edit:



The same thing happens with, for example,



row 2/.style = {row sep=2pt} 


thus it might mean that every even row/.style=... and row <row number> work fine only if one wants to change some properties of cells inside row, for example, the color of nodes borders:



every even row/.style={draw red},


but not if one aims to change row separation (see @AndréC's comment below). However it is interesting, that this is possible to do in every column sep ...



Of course, the (temporary) workaround terminates each second row of the matrix with for example [2pt], but this is annoying when the matrix is huge like here.










share|improve this question

























  • If you write every even row/.style={blue} it works. Then ...

    – AndréC
    Jan 13 at 14:03











  • @AndréC, it cover each second row with blue color. i expected that after each even row will be row separation 2pt as it is at columns.

    – Zarko
    Jan 13 at 14:11











  • Yes, I know, my example suggests that the error may not be in the style, but in another place. Otherwise, the style would not work for the blue color either.

    – AndréC
    Jan 13 at 14:12






  • 1





    The row sep option does not work with keys either row <number>, row <column number> column <column number>, every odd row

    – AndréC
    Jan 13 at 16:07








  • 1





    @AndréC, ones for nodes, ones for matrix as whole. but might be wrong.

    – Zarko
    Jan 13 at 18:18














13












13








13


0






Please consider the following mwe:



documentclass[tikz, margin=3mm]{standalone}
usetikzlibrary{matrix}

begin{document}
begin{tikzpicture}
matrix (m) [matrix of math nodes,
nodes={draw, font=footnotesize, minimum size=1em,
anchor=center,inner sep=0pt},
column sep=-pgflinewidth,
row sep=-pgflinewidth,
every even column/.style={column sep=2pt},
every even row/.style={row sep=2pt},% doesn't insert row separation
inner sep=1pt,
left delimiter={[},right delimiter={]},
]
{
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
};
end{tikzpicture}
end{document}


However every even column/.style={column sep=2pt}, yields the expected result, say, introducing additional column separation after each second column, the every even row/.style={row sep=2pt}, doesn't. Did I do something wrong or this is a bug in TikZ v3.1 (I've never tested this before, so I don't know if the same thing happens in v3.0.1)?



enter image description here



edit:



The same thing happens with, for example,



row 2/.style = {row sep=2pt} 


thus it might mean that every even row/.style=... and row <row number> work fine only if one wants to change some properties of cells inside row, for example, the color of nodes borders:



every even row/.style={draw red},


but not if one aims to change row separation (see @AndréC's comment below). However it is interesting, that this is possible to do in every column sep ...



Of course, the (temporary) workaround terminates each second row of the matrix with for example [2pt], but this is annoying when the matrix is huge like here.










share|improve this question
















Please consider the following mwe:



documentclass[tikz, margin=3mm]{standalone}
usetikzlibrary{matrix}

begin{document}
begin{tikzpicture}
matrix (m) [matrix of math nodes,
nodes={draw, font=footnotesize, minimum size=1em,
anchor=center,inner sep=0pt},
column sep=-pgflinewidth,
row sep=-pgflinewidth,
every even column/.style={column sep=2pt},
every even row/.style={row sep=2pt},% doesn't insert row separation
inner sep=1pt,
left delimiter={[},right delimiter={]},
]
{
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
};
end{tikzpicture}
end{document}


However every even column/.style={column sep=2pt}, yields the expected result, say, introducing additional column separation after each second column, the every even row/.style={row sep=2pt}, doesn't. Did I do something wrong or this is a bug in TikZ v3.1 (I've never tested this before, so I don't know if the same thing happens in v3.0.1)?



enter image description here



edit:



The same thing happens with, for example,



row 2/.style = {row sep=2pt} 


thus it might mean that every even row/.style=... and row <row number> work fine only if one wants to change some properties of cells inside row, for example, the color of nodes borders:



every even row/.style={draw red},


but not if one aims to change row separation (see @AndréC's comment below). However it is interesting, that this is possible to do in every column sep ...



Of course, the (temporary) workaround terminates each second row of the matrix with for example [2pt], but this is annoying when the matrix is huge like here.







tikz-matrix






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 13 at 21:56









Roboticist

1,64521231




1,64521231










asked Jan 13 at 13:40









ZarkoZarko

124k866163




124k866163













  • If you write every even row/.style={blue} it works. Then ...

    – AndréC
    Jan 13 at 14:03











  • @AndréC, it cover each second row with blue color. i expected that after each even row will be row separation 2pt as it is at columns.

    – Zarko
    Jan 13 at 14:11











  • Yes, I know, my example suggests that the error may not be in the style, but in another place. Otherwise, the style would not work for the blue color either.

    – AndréC
    Jan 13 at 14:12






  • 1





    The row sep option does not work with keys either row <number>, row <column number> column <column number>, every odd row

    – AndréC
    Jan 13 at 16:07








  • 1





    @AndréC, ones for nodes, ones for matrix as whole. but might be wrong.

    – Zarko
    Jan 13 at 18:18



















  • If you write every even row/.style={blue} it works. Then ...

    – AndréC
    Jan 13 at 14:03











  • @AndréC, it cover each second row with blue color. i expected that after each even row will be row separation 2pt as it is at columns.

    – Zarko
    Jan 13 at 14:11











  • Yes, I know, my example suggests that the error may not be in the style, but in another place. Otherwise, the style would not work for the blue color either.

    – AndréC
    Jan 13 at 14:12






  • 1





    The row sep option does not work with keys either row <number>, row <column number> column <column number>, every odd row

    – AndréC
    Jan 13 at 16:07








  • 1





    @AndréC, ones for nodes, ones for matrix as whole. but might be wrong.

    – Zarko
    Jan 13 at 18:18

















If you write every even row/.style={blue} it works. Then ...

– AndréC
Jan 13 at 14:03





If you write every even row/.style={blue} it works. Then ...

– AndréC
Jan 13 at 14:03













@AndréC, it cover each second row with blue color. i expected that after each even row will be row separation 2pt as it is at columns.

– Zarko
Jan 13 at 14:11





@AndréC, it cover each second row with blue color. i expected that after each even row will be row separation 2pt as it is at columns.

– Zarko
Jan 13 at 14:11













Yes, I know, my example suggests that the error may not be in the style, but in another place. Otherwise, the style would not work for the blue color either.

– AndréC
Jan 13 at 14:12





Yes, I know, my example suggests that the error may not be in the style, but in another place. Otherwise, the style would not work for the blue color either.

– AndréC
Jan 13 at 14:12




1




1





The row sep option does not work with keys either row <number>, row <column number> column <column number>, every odd row

– AndréC
Jan 13 at 16:07







The row sep option does not work with keys either row <number>, row <column number> column <column number>, every odd row

– AndréC
Jan 13 at 16:07






1




1





@AndréC, ones for nodes, ones for matrix as whole. but might be wrong.

– Zarko
Jan 13 at 18:18





@AndréC, ones for nodes, ones for matrix as whole. but might be wrong.

– Zarko
Jan 13 at 18:18










4 Answers
4






active

oldest

votes


















3














This is from a bug in the matrix library. The bug was reported in issue #504 in the PGF bug tracker.



The problem is the scope where pgfmatrixrowsep is set (the value you pass to row sep) ends before that value is actually used.



Henri Menke submitted a fix to this issue which will be in the next release of PGF.



Meanwhile, the following patch will work:



makeatletter
defpgfmatrixendrow{%
letpgf@matrix@signal@cell@end=pgf@matrix@signal@cell@end
pgf@matrix@last@cell@in@rowtrue%
xdefpgf@matrix@rowsep{pgfmatrixrowsep}% <-- Define pgf@matrix@rowsep globally
&% <-- Scope ends here
pgf@matrix@correct@calltrue%
globalpgf@matrix@fixedfalse%
pgf@y=0pt%
% The previous version used pgfmatrixrowsep, which was reset at the &
% pgf@matrix@addtolengthpgf@y{pgfmatrixrowsep}
pgf@matrix@addtolengthpgf@y{pgf@matrix@rowsep}% <-- Now use the global def
pgfutil@ifnextchar[{pgfmatrixendrow@skip}{pgf@matrix@finish@line}%
}%
makeatother


MWE:



documentclass[tikz, margin=3mm]{standalone}
usetikzlibrary{matrix}

makeatletter
defpgfmatrixendrow{%
letpgf@matrix@signal@cell@end=pgf@matrix@signal@cell@end
pgf@matrix@last@cell@in@rowtrue%
xdefpgf@matrix@rowsep{pgfmatrixrowsep}%
&pgf@matrix@correct@calltrue%
globalpgf@matrix@fixedfalse%
pgf@y=0pt%
pgf@matrix@addtolengthpgf@y{pgf@matrix@rowsep}%
pgfutil@ifnextchar[{pgfmatrixendrow@skip}{pgf@matrix@finish@line}%
}%
makeatother

begin{document}
begin{tikzpicture}
matrix (m) [matrix of math nodes,
nodes={draw, font=footnotesize, minimum size=1em,
anchor=center,inner sep=0pt},
column sep=-pgflinewidth,
row sep=-pgflinewidth,
every even column/.style={column sep=2pt},
every even row/.style={row sep=2pt},% doesn't insert row separation
inner sep=1pt,
left delimiter={[},right delimiter={]},
]
{
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
alpha & beta & gamma & delta \
};
end{tikzpicture}
end{document}





share|improve this answer

































    9














    The issue is with scopes. In order to make sure that the style code for the current row only applies to the current row, the style code is executed inside of a scope that is local to the current row. This scope is closed prior to ending the row and adding the row separation, so the value is reverted before it is applied. The solution is to make the change to the row sep global. The key row sep stores the value in pgfmatrixrowsep so we globally define this to be the updated value. Because this change is global, it applies to all rows going forward, so we need an every odd row key setting the row sep to zero to switch it back.



    documentclass[tikz, margin=3mm]{standalone}
    usetikzlibrary{matrix}

    begin{document}
    begin{tikzpicture}
    matrix (m) [matrix of math nodes,
    nodes={draw, font=footnotesize, minimum size=1em,
    anchor=center,inner sep=0pt},
    column sep=-pgflinewidth,
    every even column/.style={column sep=2pt},
    every even row/.style={/utils/exec=gdefpgfmatrixrowsep{2pt}},
    every odd row/.style={/utils/exec=gdefpgfmatrixrowsep{-pgflinewidth}},
    inner sep=1pt,
    left delimiter={[},right delimiter={]},
    ]
    {
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    };
    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer


























    • thank you for explanation. are this means, that column as treated differently (not in column scope). i expected, that rows and columns should have the same approach in executing code (this can be concluded from description of these options in manual).

      – Zarko
      Jan 13 at 18:28






    • 1





      i took liberty and add picture and slightly change code. thank you again (+1 at writing the first comment :-), for accepting i will wait a while)

      – Zarko
      Jan 13 at 18:36











    • In the code the matrices are processed rows first and then columns. Because of this, the way the style code for a row is executed once at the beginning of the row and goes out of scope at the end of the row. The style code for a column is executed many times, once for each cell in the column. I suspect the asymmetry has something to do with this, but I don't feel like reading the code carefully enough to track down the particulars.

      – Hood Chatham
      Jan 13 at 18:39






    • 1





      This is a nice analysis, +1 for that. Note, however, that you set these values globally, so every subsequent matrix will have it. Note also that the matrix library has means of "smuggling" values out of the group, which avoids making them global. Why this has not been used for every row I do not know.

      – marmot
      Jan 13 at 19:16






    • 2





      I just noticed the following comment in pgfmodulematrix.code.tex (line 109): "Between rows, an extra space given by the macro pgfmatrixrowsep is added. You can also change this value for each row by using a gdef." So it appears that this is the intended method. It might be wise to save the original value of pgfmatrixrowsep before the matrix and to restore it afterwards though, in light of @marmot's comment.

      – Circumscribe
      Jan 22 at 9:44





















    7














    This is more an extended comment than an answer. The comment concerns Hood Chathams proposal to make the dimensions global. Here is what happens:



    documentclass[tikz, margin=3mm]{standalone}
    usetikzlibrary{matrix}

    begin{document}
    begin{tikzpicture}
    matrix (m) [matrix of math nodes,
    nodes={draw, font=footnotesize, minimum size=1em,
    anchor=center,inner sep=0pt},
    inner sep=1pt,
    left delimiter={[},right delimiter={]},
    ]
    {
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    };
    end{tikzpicture}

    begin{tikzpicture}
    matrix (m) [matrix of math nodes,
    nodes={draw, font=footnotesize, minimum size=1em,
    anchor=center,inner sep=0pt},
    column sep=-pgflinewidth,
    every even column/.style={column sep=2pt},
    every even row/.style={/utils/exec=gdefpgfmatrixrowsep{2pt}},
    every odd row/.style={/utils/exec=gdefpgfmatrixrowsep{-pgflinewidth}},
    inner sep=1pt,
    left delimiter={[},right delimiter={]},
    ]
    {
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    };
    end{tikzpicture}

    begin{tikzpicture}
    matrix (m) [matrix of math nodes,
    nodes={draw, font=footnotesize, minimum size=1em,
    anchor=center,inner sep=0pt},
    inner sep=1pt,
    left delimiter={[},right delimiter={]},
    ]
    {
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    };
    end{tikzpicture}

    end{document}


    enter image description here



    Let me, however, stress that I really like the answer by Hood Chatham as a whole as it has a very nice explanation for why this happens. I just want add a word of caution.



    Here is another proposal.



    documentclass[tikz, margin=3mm]{standalone}
    usetikzlibrary{matrix}
    begin{document}
    begin{tikzpicture}
    matrix (m) [matrix of math nodes,
    nodes={draw, font=footnotesize, minimum size=1em,
    anchor=center,inner sep=0pt},
    column sep=-pgflinewidth,
    row sep=ifoddpgfmatrixcurrentrow%
    -pgflinewidth%
    else%
    2pt%
    fi,
    every even column/.style={column sep=2pt},
    left delimiter={[},right delimiter={]},
    ]
    {
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    };
    end{tikzpicture}
    end{document}


    enter image description here



    It does produce the desired output. However, it also produces warnings of the type end occurred when ifx on line 21 was incomplete. So I am definitely not claiming this proposal is better than Hood Chathams suggestion.



    Of course, a very pragmatic solution would be to use



    documentclass[tikz, margin=3mm]{standalone}
    usetikzlibrary{matrix}

    begin{document}
    begin{tikzpicture}
    matrix (m) [matrix of math nodes,
    nodes={draw, font=footnotesize, minimum size=1em,
    anchor=center,inner sep=0pt},
    column sep=-pgflinewidth,
    row sep=-pgflinewidth,
    every even column/.style={column sep=2pt},
    inner sep=1pt,
    left delimiter={[},right delimiter={]},
    ]
    {
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \[2pt]
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    };
    end{tikzpicture}
    end{document}





    share|improve this answer





















    • 1





      thank you for "extended comment (+1). it helps to understanding whats all is behind of using row styles.

      – Zarko
      Jan 13 at 20:27



















    5














    Remark: This problem appears to have been fixed, so
    your MWE should work in some future version of the matrix library.





    I just wanted to briefly mention another way in which the same result could be accomplished, so you may also consider this an extended comment.



    The values of row sep and column sep are actually passed into the pgf math engine when they're used, so you can assign a value that depends on the current row/column number.
    The following should produce the desired output:



    documentclass[tikz, margin=3mm]{standalone}
    usetikzlibrary{matrix}

    begin{document}
    begin{tikzpicture}
    matrix (m) [matrix of math nodes,
    nodes={draw, font=footnotesize, minimum size=1em,
    anchor=center,inner sep=0pt},
    row sep=iseven(pgfmatrixcurrentrow)?2pt:-pgflinewidth,
    column sep=iseven(pgfmatrixcurrentcolumn)?2pt:-pgflinewidth,
    inner sep=1pt,
    left delimiter={[},right delimiter={]},
    ]
    {
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    };
    end{tikzpicture}
    end{document}


    output



    In case you're not familiar with it, the notation <condition>?<true branch>:<false branch> means that if <condition> is true (non-zero,actually) the <true branch> is used and that the <false branch> is used otherwise.
    The functions iseven and isodd (and also isprime, wow) are documented in the pgf manual (in §99.3 on p1004 in the version for TikZ 3.1).



    There is actually one rather annoying limitation to this, which is due the fact that the argument of row sep is actually stripped of three pairs of braces ({…}) and then split at comma's before the math engine gets to see it (each comma-separated term is applied separately).
    This means that you can't use functions whose syntax includes a comma unless you wrap the entire value in at least four sets of braces ({{{{…}}}}, more is also okay), like this:



    documentclass[tikz, margin=3mm]{standalone}
    usetikzlibrary{matrix}

    begin{document}
    begin{tikzpicture}
    matrix (m) [matrix of math nodes,
    nodes={draw, font=footnotesize, minimum size=1em,
    anchor=center,inner sep=0pt},
    row sep={{{{Mod(pgfmatrixcurrentrow,3)?-pgflinewidth:2pt}}}},
    column sep={{{{Mod(pgfmatrixcurrentcolumn,3)?-pgflinewidth:2pt}}}},
    inner sep=1pt,
    left delimiter={[},right delimiter={]},
    ]
    {
    alpha & beta & gamma & delta & epsilon & zeta & eta \
    alpha & beta & gamma & delta & epsilon & zeta & eta \
    alpha & beta & gamma & delta & epsilon & zeta & eta \
    alpha & beta & gamma & delta & epsilon & zeta & eta \
    alpha & beta & gamma & delta & epsilon & zeta & eta \
    alpha & beta & gamma & delta & epsilon & zeta & eta \
    alpha & beta & gamma & delta & epsilon & zeta & eta \
    };
    end{tikzpicture}
    end{document}


    output






    share|improve this answer


























    • Thank you for sharing news about matrix report. Now we should wait for official version of the matrix library. So far i'm not able to test your solution since my MikTeX Console is down, consequently I can't update my MikTeX installation :-(. so temporary only +1, for more after my test of your solution.

      – Zarko
      Jan 22 at 21:04











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f469954%2ftikz-matrix-why-doesnt-every-even-row-work-with-row-sep-option%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    This is from a bug in the matrix library. The bug was reported in issue #504 in the PGF bug tracker.



    The problem is the scope where pgfmatrixrowsep is set (the value you pass to row sep) ends before that value is actually used.



    Henri Menke submitted a fix to this issue which will be in the next release of PGF.



    Meanwhile, the following patch will work:



    makeatletter
    defpgfmatrixendrow{%
    letpgf@matrix@signal@cell@end=pgf@matrix@signal@cell@end
    pgf@matrix@last@cell@in@rowtrue%
    xdefpgf@matrix@rowsep{pgfmatrixrowsep}% <-- Define pgf@matrix@rowsep globally
    &% <-- Scope ends here
    pgf@matrix@correct@calltrue%
    globalpgf@matrix@fixedfalse%
    pgf@y=0pt%
    % The previous version used pgfmatrixrowsep, which was reset at the &
    % pgf@matrix@addtolengthpgf@y{pgfmatrixrowsep}
    pgf@matrix@addtolengthpgf@y{pgf@matrix@rowsep}% <-- Now use the global def
    pgfutil@ifnextchar[{pgfmatrixendrow@skip}{pgf@matrix@finish@line}%
    }%
    makeatother


    MWE:



    documentclass[tikz, margin=3mm]{standalone}
    usetikzlibrary{matrix}

    makeatletter
    defpgfmatrixendrow{%
    letpgf@matrix@signal@cell@end=pgf@matrix@signal@cell@end
    pgf@matrix@last@cell@in@rowtrue%
    xdefpgf@matrix@rowsep{pgfmatrixrowsep}%
    &pgf@matrix@correct@calltrue%
    globalpgf@matrix@fixedfalse%
    pgf@y=0pt%
    pgf@matrix@addtolengthpgf@y{pgf@matrix@rowsep}%
    pgfutil@ifnextchar[{pgfmatrixendrow@skip}{pgf@matrix@finish@line}%
    }%
    makeatother

    begin{document}
    begin{tikzpicture}
    matrix (m) [matrix of math nodes,
    nodes={draw, font=footnotesize, minimum size=1em,
    anchor=center,inner sep=0pt},
    column sep=-pgflinewidth,
    row sep=-pgflinewidth,
    every even column/.style={column sep=2pt},
    every even row/.style={row sep=2pt},% doesn't insert row separation
    inner sep=1pt,
    left delimiter={[},right delimiter={]},
    ]
    {
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    alpha & beta & gamma & delta \
    };
    end{tikzpicture}
    end{document}





    share|improve this answer






























      3














      This is from a bug in the matrix library. The bug was reported in issue #504 in the PGF bug tracker.



      The problem is the scope where pgfmatrixrowsep is set (the value you pass to row sep) ends before that value is actually used.



      Henri Menke submitted a fix to this issue which will be in the next release of PGF.



      Meanwhile, the following patch will work:



      makeatletter
      defpgfmatrixendrow{%
      letpgf@matrix@signal@cell@end=pgf@matrix@signal@cell@end
      pgf@matrix@last@cell@in@rowtrue%
      xdefpgf@matrix@rowsep{pgfmatrixrowsep}% <-- Define pgf@matrix@rowsep globally
      &% <-- Scope ends here
      pgf@matrix@correct@calltrue%
      globalpgf@matrix@fixedfalse%
      pgf@y=0pt%
      % The previous version used pgfmatrixrowsep, which was reset at the &
      % pgf@matrix@addtolengthpgf@y{pgfmatrixrowsep}
      pgf@matrix@addtolengthpgf@y{pgf@matrix@rowsep}% <-- Now use the global def
      pgfutil@ifnextchar[{pgfmatrixendrow@skip}{pgf@matrix@finish@line}%
      }%
      makeatother


      MWE:



      documentclass[tikz, margin=3mm]{standalone}
      usetikzlibrary{matrix}

      makeatletter
      defpgfmatrixendrow{%
      letpgf@matrix@signal@cell@end=pgf@matrix@signal@cell@end
      pgf@matrix@last@cell@in@rowtrue%
      xdefpgf@matrix@rowsep{pgfmatrixrowsep}%
      &pgf@matrix@correct@calltrue%
      globalpgf@matrix@fixedfalse%
      pgf@y=0pt%
      pgf@matrix@addtolengthpgf@y{pgf@matrix@rowsep}%
      pgfutil@ifnextchar[{pgfmatrixendrow@skip}{pgf@matrix@finish@line}%
      }%
      makeatother

      begin{document}
      begin{tikzpicture}
      matrix (m) [matrix of math nodes,
      nodes={draw, font=footnotesize, minimum size=1em,
      anchor=center,inner sep=0pt},
      column sep=-pgflinewidth,
      row sep=-pgflinewidth,
      every even column/.style={column sep=2pt},
      every even row/.style={row sep=2pt},% doesn't insert row separation
      inner sep=1pt,
      left delimiter={[},right delimiter={]},
      ]
      {
      alpha & beta & gamma & delta \
      alpha & beta & gamma & delta \
      alpha & beta & gamma & delta \
      alpha & beta & gamma & delta \
      };
      end{tikzpicture}
      end{document}





      share|improve this answer




























        3












        3








        3







        This is from a bug in the matrix library. The bug was reported in issue #504 in the PGF bug tracker.



        The problem is the scope where pgfmatrixrowsep is set (the value you pass to row sep) ends before that value is actually used.



        Henri Menke submitted a fix to this issue which will be in the next release of PGF.



        Meanwhile, the following patch will work:



        makeatletter
        defpgfmatrixendrow{%
        letpgf@matrix@signal@cell@end=pgf@matrix@signal@cell@end
        pgf@matrix@last@cell@in@rowtrue%
        xdefpgf@matrix@rowsep{pgfmatrixrowsep}% <-- Define pgf@matrix@rowsep globally
        &% <-- Scope ends here
        pgf@matrix@correct@calltrue%
        globalpgf@matrix@fixedfalse%
        pgf@y=0pt%
        % The previous version used pgfmatrixrowsep, which was reset at the &
        % pgf@matrix@addtolengthpgf@y{pgfmatrixrowsep}
        pgf@matrix@addtolengthpgf@y{pgf@matrix@rowsep}% <-- Now use the global def
        pgfutil@ifnextchar[{pgfmatrixendrow@skip}{pgf@matrix@finish@line}%
        }%
        makeatother


        MWE:



        documentclass[tikz, margin=3mm]{standalone}
        usetikzlibrary{matrix}

        makeatletter
        defpgfmatrixendrow{%
        letpgf@matrix@signal@cell@end=pgf@matrix@signal@cell@end
        pgf@matrix@last@cell@in@rowtrue%
        xdefpgf@matrix@rowsep{pgfmatrixrowsep}%
        &pgf@matrix@correct@calltrue%
        globalpgf@matrix@fixedfalse%
        pgf@y=0pt%
        pgf@matrix@addtolengthpgf@y{pgf@matrix@rowsep}%
        pgfutil@ifnextchar[{pgfmatrixendrow@skip}{pgf@matrix@finish@line}%
        }%
        makeatother

        begin{document}
        begin{tikzpicture}
        matrix (m) [matrix of math nodes,
        nodes={draw, font=footnotesize, minimum size=1em,
        anchor=center,inner sep=0pt},
        column sep=-pgflinewidth,
        row sep=-pgflinewidth,
        every even column/.style={column sep=2pt},
        every even row/.style={row sep=2pt},% doesn't insert row separation
        inner sep=1pt,
        left delimiter={[},right delimiter={]},
        ]
        {
        alpha & beta & gamma & delta \
        alpha & beta & gamma & delta \
        alpha & beta & gamma & delta \
        alpha & beta & gamma & delta \
        };
        end{tikzpicture}
        end{document}





        share|improve this answer















        This is from a bug in the matrix library. The bug was reported in issue #504 in the PGF bug tracker.



        The problem is the scope where pgfmatrixrowsep is set (the value you pass to row sep) ends before that value is actually used.



        Henri Menke submitted a fix to this issue which will be in the next release of PGF.



        Meanwhile, the following patch will work:



        makeatletter
        defpgfmatrixendrow{%
        letpgf@matrix@signal@cell@end=pgf@matrix@signal@cell@end
        pgf@matrix@last@cell@in@rowtrue%
        xdefpgf@matrix@rowsep{pgfmatrixrowsep}% <-- Define pgf@matrix@rowsep globally
        &% <-- Scope ends here
        pgf@matrix@correct@calltrue%
        globalpgf@matrix@fixedfalse%
        pgf@y=0pt%
        % The previous version used pgfmatrixrowsep, which was reset at the &
        % pgf@matrix@addtolengthpgf@y{pgfmatrixrowsep}
        pgf@matrix@addtolengthpgf@y{pgf@matrix@rowsep}% <-- Now use the global def
        pgfutil@ifnextchar[{pgfmatrixendrow@skip}{pgf@matrix@finish@line}%
        }%
        makeatother


        MWE:



        documentclass[tikz, margin=3mm]{standalone}
        usetikzlibrary{matrix}

        makeatletter
        defpgfmatrixendrow{%
        letpgf@matrix@signal@cell@end=pgf@matrix@signal@cell@end
        pgf@matrix@last@cell@in@rowtrue%
        xdefpgf@matrix@rowsep{pgfmatrixrowsep}%
        &pgf@matrix@correct@calltrue%
        globalpgf@matrix@fixedfalse%
        pgf@y=0pt%
        pgf@matrix@addtolengthpgf@y{pgf@matrix@rowsep}%
        pgfutil@ifnextchar[{pgfmatrixendrow@skip}{pgf@matrix@finish@line}%
        }%
        makeatother

        begin{document}
        begin{tikzpicture}
        matrix (m) [matrix of math nodes,
        nodes={draw, font=footnotesize, minimum size=1em,
        anchor=center,inner sep=0pt},
        column sep=-pgflinewidth,
        row sep=-pgflinewidth,
        every even column/.style={column sep=2pt},
        every even row/.style={row sep=2pt},% doesn't insert row separation
        inner sep=1pt,
        left delimiter={[},right delimiter={]},
        ]
        {
        alpha & beta & gamma & delta \
        alpha & beta & gamma & delta \
        alpha & beta & gamma & delta \
        alpha & beta & gamma & delta \
        };
        end{tikzpicture}
        end{document}






        share|improve this answer














        share|improve this answer



        share|improve this answer








        answered Feb 6 at 18:54


























        community wiki





        Phelype Oleinik
























            9














            The issue is with scopes. In order to make sure that the style code for the current row only applies to the current row, the style code is executed inside of a scope that is local to the current row. This scope is closed prior to ending the row and adding the row separation, so the value is reverted before it is applied. The solution is to make the change to the row sep global. The key row sep stores the value in pgfmatrixrowsep so we globally define this to be the updated value. Because this change is global, it applies to all rows going forward, so we need an every odd row key setting the row sep to zero to switch it back.



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            every even row/.style={/utils/exec=gdefpgfmatrixrowsep{2pt}},
            every odd row/.style={/utils/exec=gdefpgfmatrixrowsep{-pgflinewidth}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer


























            • thank you for explanation. are this means, that column as treated differently (not in column scope). i expected, that rows and columns should have the same approach in executing code (this can be concluded from description of these options in manual).

              – Zarko
              Jan 13 at 18:28






            • 1





              i took liberty and add picture and slightly change code. thank you again (+1 at writing the first comment :-), for accepting i will wait a while)

              – Zarko
              Jan 13 at 18:36











            • In the code the matrices are processed rows first and then columns. Because of this, the way the style code for a row is executed once at the beginning of the row and goes out of scope at the end of the row. The style code for a column is executed many times, once for each cell in the column. I suspect the asymmetry has something to do with this, but I don't feel like reading the code carefully enough to track down the particulars.

              – Hood Chatham
              Jan 13 at 18:39






            • 1





              This is a nice analysis, +1 for that. Note, however, that you set these values globally, so every subsequent matrix will have it. Note also that the matrix library has means of "smuggling" values out of the group, which avoids making them global. Why this has not been used for every row I do not know.

              – marmot
              Jan 13 at 19:16






            • 2





              I just noticed the following comment in pgfmodulematrix.code.tex (line 109): "Between rows, an extra space given by the macro pgfmatrixrowsep is added. You can also change this value for each row by using a gdef." So it appears that this is the intended method. It might be wise to save the original value of pgfmatrixrowsep before the matrix and to restore it afterwards though, in light of @marmot's comment.

              – Circumscribe
              Jan 22 at 9:44


















            9














            The issue is with scopes. In order to make sure that the style code for the current row only applies to the current row, the style code is executed inside of a scope that is local to the current row. This scope is closed prior to ending the row and adding the row separation, so the value is reverted before it is applied. The solution is to make the change to the row sep global. The key row sep stores the value in pgfmatrixrowsep so we globally define this to be the updated value. Because this change is global, it applies to all rows going forward, so we need an every odd row key setting the row sep to zero to switch it back.



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            every even row/.style={/utils/exec=gdefpgfmatrixrowsep{2pt}},
            every odd row/.style={/utils/exec=gdefpgfmatrixrowsep{-pgflinewidth}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer


























            • thank you for explanation. are this means, that column as treated differently (not in column scope). i expected, that rows and columns should have the same approach in executing code (this can be concluded from description of these options in manual).

              – Zarko
              Jan 13 at 18:28






            • 1





              i took liberty and add picture and slightly change code. thank you again (+1 at writing the first comment :-), for accepting i will wait a while)

              – Zarko
              Jan 13 at 18:36











            • In the code the matrices are processed rows first and then columns. Because of this, the way the style code for a row is executed once at the beginning of the row and goes out of scope at the end of the row. The style code for a column is executed many times, once for each cell in the column. I suspect the asymmetry has something to do with this, but I don't feel like reading the code carefully enough to track down the particulars.

              – Hood Chatham
              Jan 13 at 18:39






            • 1





              This is a nice analysis, +1 for that. Note, however, that you set these values globally, so every subsequent matrix will have it. Note also that the matrix library has means of "smuggling" values out of the group, which avoids making them global. Why this has not been used for every row I do not know.

              – marmot
              Jan 13 at 19:16






            • 2





              I just noticed the following comment in pgfmodulematrix.code.tex (line 109): "Between rows, an extra space given by the macro pgfmatrixrowsep is added. You can also change this value for each row by using a gdef." So it appears that this is the intended method. It might be wise to save the original value of pgfmatrixrowsep before the matrix and to restore it afterwards though, in light of @marmot's comment.

              – Circumscribe
              Jan 22 at 9:44
















            9












            9








            9







            The issue is with scopes. In order to make sure that the style code for the current row only applies to the current row, the style code is executed inside of a scope that is local to the current row. This scope is closed prior to ending the row and adding the row separation, so the value is reverted before it is applied. The solution is to make the change to the row sep global. The key row sep stores the value in pgfmatrixrowsep so we globally define this to be the updated value. Because this change is global, it applies to all rows going forward, so we need an every odd row key setting the row sep to zero to switch it back.



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            every even row/.style={/utils/exec=gdefpgfmatrixrowsep{2pt}},
            every odd row/.style={/utils/exec=gdefpgfmatrixrowsep{-pgflinewidth}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer















            The issue is with scopes. In order to make sure that the style code for the current row only applies to the current row, the style code is executed inside of a scope that is local to the current row. This scope is closed prior to ending the row and adding the row separation, so the value is reverted before it is applied. The solution is to make the change to the row sep global. The key row sep stores the value in pgfmatrixrowsep so we globally define this to be the updated value. Because this change is global, it applies to all rows going forward, so we need an every odd row key setting the row sep to zero to switch it back.



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            every even row/.style={/utils/exec=gdefpgfmatrixrowsep{2pt}},
            every odd row/.style={/utils/exec=gdefpgfmatrixrowsep{-pgflinewidth}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 13 at 18:34









            Zarko

            124k866163




            124k866163










            answered Jan 13 at 18:18









            Hood ChathamHood Chatham

            4,2991428




            4,2991428













            • thank you for explanation. are this means, that column as treated differently (not in column scope). i expected, that rows and columns should have the same approach in executing code (this can be concluded from description of these options in manual).

              – Zarko
              Jan 13 at 18:28






            • 1





              i took liberty and add picture and slightly change code. thank you again (+1 at writing the first comment :-), for accepting i will wait a while)

              – Zarko
              Jan 13 at 18:36











            • In the code the matrices are processed rows first and then columns. Because of this, the way the style code for a row is executed once at the beginning of the row and goes out of scope at the end of the row. The style code for a column is executed many times, once for each cell in the column. I suspect the asymmetry has something to do with this, but I don't feel like reading the code carefully enough to track down the particulars.

              – Hood Chatham
              Jan 13 at 18:39






            • 1





              This is a nice analysis, +1 for that. Note, however, that you set these values globally, so every subsequent matrix will have it. Note also that the matrix library has means of "smuggling" values out of the group, which avoids making them global. Why this has not been used for every row I do not know.

              – marmot
              Jan 13 at 19:16






            • 2





              I just noticed the following comment in pgfmodulematrix.code.tex (line 109): "Between rows, an extra space given by the macro pgfmatrixrowsep is added. You can also change this value for each row by using a gdef." So it appears that this is the intended method. It might be wise to save the original value of pgfmatrixrowsep before the matrix and to restore it afterwards though, in light of @marmot's comment.

              – Circumscribe
              Jan 22 at 9:44





















            • thank you for explanation. are this means, that column as treated differently (not in column scope). i expected, that rows and columns should have the same approach in executing code (this can be concluded from description of these options in manual).

              – Zarko
              Jan 13 at 18:28






            • 1





              i took liberty and add picture and slightly change code. thank you again (+1 at writing the first comment :-), for accepting i will wait a while)

              – Zarko
              Jan 13 at 18:36











            • In the code the matrices are processed rows first and then columns. Because of this, the way the style code for a row is executed once at the beginning of the row and goes out of scope at the end of the row. The style code for a column is executed many times, once for each cell in the column. I suspect the asymmetry has something to do with this, but I don't feel like reading the code carefully enough to track down the particulars.

              – Hood Chatham
              Jan 13 at 18:39






            • 1





              This is a nice analysis, +1 for that. Note, however, that you set these values globally, so every subsequent matrix will have it. Note also that the matrix library has means of "smuggling" values out of the group, which avoids making them global. Why this has not been used for every row I do not know.

              – marmot
              Jan 13 at 19:16






            • 2





              I just noticed the following comment in pgfmodulematrix.code.tex (line 109): "Between rows, an extra space given by the macro pgfmatrixrowsep is added. You can also change this value for each row by using a gdef." So it appears that this is the intended method. It might be wise to save the original value of pgfmatrixrowsep before the matrix and to restore it afterwards though, in light of @marmot's comment.

              – Circumscribe
              Jan 22 at 9:44



















            thank you for explanation. are this means, that column as treated differently (not in column scope). i expected, that rows and columns should have the same approach in executing code (this can be concluded from description of these options in manual).

            – Zarko
            Jan 13 at 18:28





            thank you for explanation. are this means, that column as treated differently (not in column scope). i expected, that rows and columns should have the same approach in executing code (this can be concluded from description of these options in manual).

            – Zarko
            Jan 13 at 18:28




            1




            1





            i took liberty and add picture and slightly change code. thank you again (+1 at writing the first comment :-), for accepting i will wait a while)

            – Zarko
            Jan 13 at 18:36





            i took liberty and add picture and slightly change code. thank you again (+1 at writing the first comment :-), for accepting i will wait a while)

            – Zarko
            Jan 13 at 18:36













            In the code the matrices are processed rows first and then columns. Because of this, the way the style code for a row is executed once at the beginning of the row and goes out of scope at the end of the row. The style code for a column is executed many times, once for each cell in the column. I suspect the asymmetry has something to do with this, but I don't feel like reading the code carefully enough to track down the particulars.

            – Hood Chatham
            Jan 13 at 18:39





            In the code the matrices are processed rows first and then columns. Because of this, the way the style code for a row is executed once at the beginning of the row and goes out of scope at the end of the row. The style code for a column is executed many times, once for each cell in the column. I suspect the asymmetry has something to do with this, but I don't feel like reading the code carefully enough to track down the particulars.

            – Hood Chatham
            Jan 13 at 18:39




            1




            1





            This is a nice analysis, +1 for that. Note, however, that you set these values globally, so every subsequent matrix will have it. Note also that the matrix library has means of "smuggling" values out of the group, which avoids making them global. Why this has not been used for every row I do not know.

            – marmot
            Jan 13 at 19:16





            This is a nice analysis, +1 for that. Note, however, that you set these values globally, so every subsequent matrix will have it. Note also that the matrix library has means of "smuggling" values out of the group, which avoids making them global. Why this has not been used for every row I do not know.

            – marmot
            Jan 13 at 19:16




            2




            2





            I just noticed the following comment in pgfmodulematrix.code.tex (line 109): "Between rows, an extra space given by the macro pgfmatrixrowsep is added. You can also change this value for each row by using a gdef." So it appears that this is the intended method. It might be wise to save the original value of pgfmatrixrowsep before the matrix and to restore it afterwards though, in light of @marmot's comment.

            – Circumscribe
            Jan 22 at 9:44







            I just noticed the following comment in pgfmodulematrix.code.tex (line 109): "Between rows, an extra space given by the macro pgfmatrixrowsep is added. You can also change this value for each row by using a gdef." So it appears that this is the intended method. It might be wise to save the original value of pgfmatrixrowsep before the matrix and to restore it afterwards though, in light of @marmot's comment.

            – Circumscribe
            Jan 22 at 9:44













            7














            This is more an extended comment than an answer. The comment concerns Hood Chathams proposal to make the dimensions global. Here is what happens:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            every even row/.style={/utils/exec=gdefpgfmatrixrowsep{2pt}},
            every odd row/.style={/utils/exec=gdefpgfmatrixrowsep{-pgflinewidth}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            end{document}


            enter image description here



            Let me, however, stress that I really like the answer by Hood Chatham as a whole as it has a very nice explanation for why this happens. I just want add a word of caution.



            Here is another proposal.



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}
            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            row sep=ifoddpgfmatrixcurrentrow%
            -pgflinewidth%
            else%
            2pt%
            fi,
            every even column/.style={column sep=2pt},
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            enter image description here



            It does produce the desired output. However, it also produces warnings of the type end occurred when ifx on line 21 was incomplete. So I am definitely not claiming this proposal is better than Hood Chathams suggestion.



            Of course, a very pragmatic solution would be to use



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            row sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \[2pt]
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}





            share|improve this answer





















            • 1





              thank you for "extended comment (+1). it helps to understanding whats all is behind of using row styles.

              – Zarko
              Jan 13 at 20:27
















            7














            This is more an extended comment than an answer. The comment concerns Hood Chathams proposal to make the dimensions global. Here is what happens:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            every even row/.style={/utils/exec=gdefpgfmatrixrowsep{2pt}},
            every odd row/.style={/utils/exec=gdefpgfmatrixrowsep{-pgflinewidth}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            end{document}


            enter image description here



            Let me, however, stress that I really like the answer by Hood Chatham as a whole as it has a very nice explanation for why this happens. I just want add a word of caution.



            Here is another proposal.



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}
            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            row sep=ifoddpgfmatrixcurrentrow%
            -pgflinewidth%
            else%
            2pt%
            fi,
            every even column/.style={column sep=2pt},
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            enter image description here



            It does produce the desired output. However, it also produces warnings of the type end occurred when ifx on line 21 was incomplete. So I am definitely not claiming this proposal is better than Hood Chathams suggestion.



            Of course, a very pragmatic solution would be to use



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            row sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \[2pt]
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}





            share|improve this answer





















            • 1





              thank you for "extended comment (+1). it helps to understanding whats all is behind of using row styles.

              – Zarko
              Jan 13 at 20:27














            7












            7








            7







            This is more an extended comment than an answer. The comment concerns Hood Chathams proposal to make the dimensions global. Here is what happens:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            every even row/.style={/utils/exec=gdefpgfmatrixrowsep{2pt}},
            every odd row/.style={/utils/exec=gdefpgfmatrixrowsep{-pgflinewidth}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            end{document}


            enter image description here



            Let me, however, stress that I really like the answer by Hood Chatham as a whole as it has a very nice explanation for why this happens. I just want add a word of caution.



            Here is another proposal.



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}
            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            row sep=ifoddpgfmatrixcurrentrow%
            -pgflinewidth%
            else%
            2pt%
            fi,
            every even column/.style={column sep=2pt},
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            enter image description here



            It does produce the desired output. However, it also produces warnings of the type end occurred when ifx on line 21 was incomplete. So I am definitely not claiming this proposal is better than Hood Chathams suggestion.



            Of course, a very pragmatic solution would be to use



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            row sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \[2pt]
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}





            share|improve this answer















            This is more an extended comment than an answer. The comment concerns Hood Chathams proposal to make the dimensions global. Here is what happens:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            every even row/.style={/utils/exec=gdefpgfmatrixrowsep{2pt}},
            every odd row/.style={/utils/exec=gdefpgfmatrixrowsep{-pgflinewidth}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}

            end{document}


            enter image description here



            Let me, however, stress that I really like the answer by Hood Chatham as a whole as it has a very nice explanation for why this happens. I just want add a word of caution.



            Here is another proposal.



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}
            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            row sep=ifoddpgfmatrixcurrentrow%
            -pgflinewidth%
            else%
            2pt%
            fi,
            every even column/.style={column sep=2pt},
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            enter image description here



            It does produce the desired output. However, it also produces warnings of the type end occurred when ifx on line 21 was incomplete. So I am definitely not claiming this proposal is better than Hood Chathams suggestion.



            Of course, a very pragmatic solution would be to use



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            column sep=-pgflinewidth,
            row sep=-pgflinewidth,
            every even column/.style={column sep=2pt},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \[2pt]
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 14 at 4:31

























            answered Jan 13 at 19:53









            marmotmarmot

            99.9k4115221




            99.9k4115221








            • 1





              thank you for "extended comment (+1). it helps to understanding whats all is behind of using row styles.

              – Zarko
              Jan 13 at 20:27














            • 1





              thank you for "extended comment (+1). it helps to understanding whats all is behind of using row styles.

              – Zarko
              Jan 13 at 20:27








            1




            1





            thank you for "extended comment (+1). it helps to understanding whats all is behind of using row styles.

            – Zarko
            Jan 13 at 20:27





            thank you for "extended comment (+1). it helps to understanding whats all is behind of using row styles.

            – Zarko
            Jan 13 at 20:27











            5














            Remark: This problem appears to have been fixed, so
            your MWE should work in some future version of the matrix library.





            I just wanted to briefly mention another way in which the same result could be accomplished, so you may also consider this an extended comment.



            The values of row sep and column sep are actually passed into the pgf math engine when they're used, so you can assign a value that depends on the current row/column number.
            The following should produce the desired output:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            row sep=iseven(pgfmatrixcurrentrow)?2pt:-pgflinewidth,
            column sep=iseven(pgfmatrixcurrentcolumn)?2pt:-pgflinewidth,
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            output



            In case you're not familiar with it, the notation <condition>?<true branch>:<false branch> means that if <condition> is true (non-zero,actually) the <true branch> is used and that the <false branch> is used otherwise.
            The functions iseven and isodd (and also isprime, wow) are documented in the pgf manual (in §99.3 on p1004 in the version for TikZ 3.1).



            There is actually one rather annoying limitation to this, which is due the fact that the argument of row sep is actually stripped of three pairs of braces ({…}) and then split at comma's before the math engine gets to see it (each comma-separated term is applied separately).
            This means that you can't use functions whose syntax includes a comma unless you wrap the entire value in at least four sets of braces ({{{{…}}}}, more is also okay), like this:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            row sep={{{{Mod(pgfmatrixcurrentrow,3)?-pgflinewidth:2pt}}}},
            column sep={{{{Mod(pgfmatrixcurrentcolumn,3)?-pgflinewidth:2pt}}}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            };
            end{tikzpicture}
            end{document}


            output






            share|improve this answer


























            • Thank you for sharing news about matrix report. Now we should wait for official version of the matrix library. So far i'm not able to test your solution since my MikTeX Console is down, consequently I can't update my MikTeX installation :-(. so temporary only +1, for more after my test of your solution.

              – Zarko
              Jan 22 at 21:04
















            5














            Remark: This problem appears to have been fixed, so
            your MWE should work in some future version of the matrix library.





            I just wanted to briefly mention another way in which the same result could be accomplished, so you may also consider this an extended comment.



            The values of row sep and column sep are actually passed into the pgf math engine when they're used, so you can assign a value that depends on the current row/column number.
            The following should produce the desired output:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            row sep=iseven(pgfmatrixcurrentrow)?2pt:-pgflinewidth,
            column sep=iseven(pgfmatrixcurrentcolumn)?2pt:-pgflinewidth,
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            output



            In case you're not familiar with it, the notation <condition>?<true branch>:<false branch> means that if <condition> is true (non-zero,actually) the <true branch> is used and that the <false branch> is used otherwise.
            The functions iseven and isodd (and also isprime, wow) are documented in the pgf manual (in §99.3 on p1004 in the version for TikZ 3.1).



            There is actually one rather annoying limitation to this, which is due the fact that the argument of row sep is actually stripped of three pairs of braces ({…}) and then split at comma's before the math engine gets to see it (each comma-separated term is applied separately).
            This means that you can't use functions whose syntax includes a comma unless you wrap the entire value in at least four sets of braces ({{{{…}}}}, more is also okay), like this:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            row sep={{{{Mod(pgfmatrixcurrentrow,3)?-pgflinewidth:2pt}}}},
            column sep={{{{Mod(pgfmatrixcurrentcolumn,3)?-pgflinewidth:2pt}}}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            };
            end{tikzpicture}
            end{document}


            output






            share|improve this answer


























            • Thank you for sharing news about matrix report. Now we should wait for official version of the matrix library. So far i'm not able to test your solution since my MikTeX Console is down, consequently I can't update my MikTeX installation :-(. so temporary only +1, for more after my test of your solution.

              – Zarko
              Jan 22 at 21:04














            5












            5








            5







            Remark: This problem appears to have been fixed, so
            your MWE should work in some future version of the matrix library.





            I just wanted to briefly mention another way in which the same result could be accomplished, so you may also consider this an extended comment.



            The values of row sep and column sep are actually passed into the pgf math engine when they're used, so you can assign a value that depends on the current row/column number.
            The following should produce the desired output:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            row sep=iseven(pgfmatrixcurrentrow)?2pt:-pgflinewidth,
            column sep=iseven(pgfmatrixcurrentcolumn)?2pt:-pgflinewidth,
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            output



            In case you're not familiar with it, the notation <condition>?<true branch>:<false branch> means that if <condition> is true (non-zero,actually) the <true branch> is used and that the <false branch> is used otherwise.
            The functions iseven and isodd (and also isprime, wow) are documented in the pgf manual (in §99.3 on p1004 in the version for TikZ 3.1).



            There is actually one rather annoying limitation to this, which is due the fact that the argument of row sep is actually stripped of three pairs of braces ({…}) and then split at comma's before the math engine gets to see it (each comma-separated term is applied separately).
            This means that you can't use functions whose syntax includes a comma unless you wrap the entire value in at least four sets of braces ({{{{…}}}}, more is also okay), like this:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            row sep={{{{Mod(pgfmatrixcurrentrow,3)?-pgflinewidth:2pt}}}},
            column sep={{{{Mod(pgfmatrixcurrentcolumn,3)?-pgflinewidth:2pt}}}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            };
            end{tikzpicture}
            end{document}


            output






            share|improve this answer















            Remark: This problem appears to have been fixed, so
            your MWE should work in some future version of the matrix library.





            I just wanted to briefly mention another way in which the same result could be accomplished, so you may also consider this an extended comment.



            The values of row sep and column sep are actually passed into the pgf math engine when they're used, so you can assign a value that depends on the current row/column number.
            The following should produce the desired output:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            row sep=iseven(pgfmatrixcurrentrow)?2pt:-pgflinewidth,
            column sep=iseven(pgfmatrixcurrentcolumn)?2pt:-pgflinewidth,
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            alpha & beta & gamma & delta \
            };
            end{tikzpicture}
            end{document}


            output



            In case you're not familiar with it, the notation <condition>?<true branch>:<false branch> means that if <condition> is true (non-zero,actually) the <true branch> is used and that the <false branch> is used otherwise.
            The functions iseven and isodd (and also isprime, wow) are documented in the pgf manual (in §99.3 on p1004 in the version for TikZ 3.1).



            There is actually one rather annoying limitation to this, which is due the fact that the argument of row sep is actually stripped of three pairs of braces ({…}) and then split at comma's before the math engine gets to see it (each comma-separated term is applied separately).
            This means that you can't use functions whose syntax includes a comma unless you wrap the entire value in at least four sets of braces ({{{{…}}}}, more is also okay), like this:



            documentclass[tikz, margin=3mm]{standalone}
            usetikzlibrary{matrix}

            begin{document}
            begin{tikzpicture}
            matrix (m) [matrix of math nodes,
            nodes={draw, font=footnotesize, minimum size=1em,
            anchor=center,inner sep=0pt},
            row sep={{{{Mod(pgfmatrixcurrentrow,3)?-pgflinewidth:2pt}}}},
            column sep={{{{Mod(pgfmatrixcurrentcolumn,3)?-pgflinewidth:2pt}}}},
            inner sep=1pt,
            left delimiter={[},right delimiter={]},
            ]
            {
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            alpha & beta & gamma & delta & epsilon & zeta & eta \
            };
            end{tikzpicture}
            end{document}


            output







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 23 at 7:56

























            answered Jan 22 at 20:36









            CircumscribeCircumscribe

            6,76121039




            6,76121039













            • Thank you for sharing news about matrix report. Now we should wait for official version of the matrix library. So far i'm not able to test your solution since my MikTeX Console is down, consequently I can't update my MikTeX installation :-(. so temporary only +1, for more after my test of your solution.

              – Zarko
              Jan 22 at 21:04



















            • Thank you for sharing news about matrix report. Now we should wait for official version of the matrix library. So far i'm not able to test your solution since my MikTeX Console is down, consequently I can't update my MikTeX installation :-(. so temporary only +1, for more after my test of your solution.

              – Zarko
              Jan 22 at 21:04

















            Thank you for sharing news about matrix report. Now we should wait for official version of the matrix library. So far i'm not able to test your solution since my MikTeX Console is down, consequently I can't update my MikTeX installation :-(. so temporary only +1, for more after my test of your solution.

            – Zarko
            Jan 22 at 21:04





            Thank you for sharing news about matrix report. Now we should wait for official version of the matrix library. So far i'm not able to test your solution since my MikTeX Console is down, consequently I can't update my MikTeX installation :-(. so temporary only +1, for more after my test of your solution.

            – Zarko
            Jan 22 at 21:04


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f469954%2ftikz-matrix-why-doesnt-every-even-row-work-with-row-sep-option%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

            Npm cannot find a required file even through it is in the searched directory