Can I put fbox along the diagonal so that they touch each other?












3















I am creating a block-diagonal matrix and want to use boxes along the diagonal but the boxes don't touch each other, so it looks funny.



What's a workaround for this?



Here's my code:



documentclass{article}
usepackage{amsmath}
begin{document}
[
begin{bmatrix}
fbox{$B_1$} & 0 & 0 \
0 & fbox{$B_2$} & 0 \
0 & 0 & fbox{$B_3$} \
end{bmatrix}
]
end{document}


something like the matrix in the middle ...of this answer (but without the red and color filling)



Squares in Matrix



Thanks,










share|improve this question

























  • Hi @cfr, nope, I will try that now. But the other issue is: the boxes don't touch each other, which I would like for a block-diagonal matrix....

    – user58865
    Sep 21 '16 at 3:23
















3















I am creating a block-diagonal matrix and want to use boxes along the diagonal but the boxes don't touch each other, so it looks funny.



What's a workaround for this?



Here's my code:



documentclass{article}
usepackage{amsmath}
begin{document}
[
begin{bmatrix}
fbox{$B_1$} & 0 & 0 \
0 & fbox{$B_2$} & 0 \
0 & 0 & fbox{$B_3$} \
end{bmatrix}
]
end{document}


something like the matrix in the middle ...of this answer (but without the red and color filling)



Squares in Matrix



Thanks,










share|improve this question

























  • Hi @cfr, nope, I will try that now. But the other issue is: the boxes don't touch each other, which I would like for a block-diagonal matrix....

    – user58865
    Sep 21 '16 at 3:23














3












3








3








I am creating a block-diagonal matrix and want to use boxes along the diagonal but the boxes don't touch each other, so it looks funny.



What's a workaround for this?



Here's my code:



documentclass{article}
usepackage{amsmath}
begin{document}
[
begin{bmatrix}
fbox{$B_1$} & 0 & 0 \
0 & fbox{$B_2$} & 0 \
0 & 0 & fbox{$B_3$} \
end{bmatrix}
]
end{document}


something like the matrix in the middle ...of this answer (but without the red and color filling)



Squares in Matrix



Thanks,










share|improve this question
















I am creating a block-diagonal matrix and want to use boxes along the diagonal but the boxes don't touch each other, so it looks funny.



What's a workaround for this?



Here's my code:



documentclass{article}
usepackage{amsmath}
begin{document}
[
begin{bmatrix}
fbox{$B_1$} & 0 & 0 \
0 & fbox{$B_2$} & 0 \
0 & 0 & fbox{$B_3$} \
end{bmatrix}
]
end{document}


something like the matrix in the middle ...of this answer (but without the red and color filling)



Squares in Matrix



Thanks,







boxes matrices






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:35









Community

1




1










asked Sep 21 '16 at 2:51









user58865user58865

1




1













  • Hi @cfr, nope, I will try that now. But the other issue is: the boxes don't touch each other, which I would like for a block-diagonal matrix....

    – user58865
    Sep 21 '16 at 3:23



















  • Hi @cfr, nope, I will try that now. But the other issue is: the boxes don't touch each other, which I would like for a block-diagonal matrix....

    – user58865
    Sep 21 '16 at 3:23

















Hi @cfr, nope, I will try that now. But the other issue is: the boxes don't touch each other, which I would like for a block-diagonal matrix....

– user58865
Sep 21 '16 at 3:23





Hi @cfr, nope, I will try that now. But the other issue is: the boxes don't touch each other, which I would like for a block-diagonal matrix....

– user58865
Sep 21 '16 at 3:23










2 Answers
2






active

oldest

votes


















7














The space between the columns is controlled by the dimen register arraycolsep:



documentclass{article}
usepackage{amsmath}
begin{document}
[
setlength{arraycolsep}{0pt}
begin{bmatrix}
fbox{$B_1$} & 0 & 0 \
0 & fbox{$B_2$} & 0 \
0 & 0 & fbox{$B_3$} \
end{bmatrix}
]
end{document}



Result




Without touching the delimiters:



documentclass{article}
usepackage{amsmath}
begin{document}
[
setlength{arraycolsep}{0pt}
begin{bmatrix}
,fbox{$B_1$} & 0 & 0, \
,0 & fbox{$B_2$} & 0, \
,0 & 0 & fbox{$B_3$}, \
end{bmatrix}
]
end{document}



Result




The size of the delimiters are at least delimiterfactor per mille of the formula height or the height of the formula minus delimitershortfall. Full size is achieved by either



delimiterfactor=1000relax



or



setlength{delimitershortfall}{0pt}


Example:



documentclass{article}
usepackage{amsmath}
begin{document}
[
setlength{arraycolsep}{0pt}
% delimiterfactor=1000 %
setlength{delimitershortfall}{0pt}
begin{bmatrix}
,fbox{$B_1$} & 0 & 0, \
,0 & fbox{$B_2$} & 0, \
,0 & 0 & fbox{$B_3$}, \
end{bmatrix}
]
end{document}



Result




Colored boxes would also be possible as in Zarko's answer:



documentclass{article}
usepackage{amsmath}
usepackage{xcolor}
begin{document}
[
setlength{arraycolsep}{0pt}
setlength{delimitershortfall}{0pt}
newcommand*{myfbox}[1]{%
fcolorbox{red}{red!20!white}{$#1$}%
}
begin{bmatrix}
,myfbox{B_1} & 0 & 0, \
,0 & myfbox{B_2} & 0, \
,0 & 0 & myfbox{B_3}, \
end{bmatrix}
]
end{document}



Result with colored boxes







share|improve this answer


























  • awesome, @Heiko. How could I get the matrix brackets to be big enough to accommodate the boxes?

    – user58865
    Sep 21 '16 at 4:45











  • @user58865 See updated answer.

    – Heiko Oberdiek
    Sep 21 '16 at 5:05



















5














Like this?



enter image description here



Well, this matrix is drawn ...



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

begin{document}
[
begin{tikzpicture}
matrix (m1) [matrix of nodes,
left delimiter={[}, right delimiter={]},
row sep=-0.5pt,column sep=-0.5pt,
every node/.style={inner sep=5pt}
]
{
|[draw]| $B_1$ & 0 & 0 \
0 & |[draw]| $B_2$ & 0 \
0 & 0 & |[draw]| $B_3$ \
};
end{tikzpicture}
]
end{document}


by tikz with TikZ library matrix. Distance between cells of matrix as well to its brackets are set by inner sep=5pt. Cells with "frame" have option |[draw]|.



Addendum:
Since the matrix is now actually image, it is simple to present on more fancy ways. For example as:



enter image description here



MWE for above version of matrix is:



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

begin{document}
[
begin{tikzpicture}
matrix (m1) [matrix of nodes,
left delimiter={[}, right delimiter={]},
row sep=-0.5pt,column sep=-0.5pt,
every node/.style={inner sep=5pt},
F/.style = {draw=red, line width=0.5pt, fill=red!20}
]
{
|[F]| $B_1$ & 0 & 0 \
0 & |[F]| $B_2$ & 0 \
0 & 0 & |[F]| $B_3$ \
};
end{tikzpicture}
]
end{document}





share|improve this answer

























    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%2f330586%2fcan-i-put-fbox-along-the-diagonal-so-that-they-touch-each-other%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    The space between the columns is controlled by the dimen register arraycolsep:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    begin{bmatrix}
    fbox{$B_1$} & 0 & 0 \
    0 & fbox{$B_2$} & 0 \
    0 & 0 & fbox{$B_3$} \
    end{bmatrix}
    ]
    end{document}



    Result




    Without touching the delimiters:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    begin{bmatrix}
    ,fbox{$B_1$} & 0 & 0, \
    ,0 & fbox{$B_2$} & 0, \
    ,0 & 0 & fbox{$B_3$}, \
    end{bmatrix}
    ]
    end{document}



    Result




    The size of the delimiters are at least delimiterfactor per mille of the formula height or the height of the formula minus delimitershortfall. Full size is achieved by either



    delimiterfactor=1000relax



    or



    setlength{delimitershortfall}{0pt}


    Example:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    % delimiterfactor=1000 %
    setlength{delimitershortfall}{0pt}
    begin{bmatrix}
    ,fbox{$B_1$} & 0 & 0, \
    ,0 & fbox{$B_2$} & 0, \
    ,0 & 0 & fbox{$B_3$}, \
    end{bmatrix}
    ]
    end{document}



    Result




    Colored boxes would also be possible as in Zarko's answer:



    documentclass{article}
    usepackage{amsmath}
    usepackage{xcolor}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    setlength{delimitershortfall}{0pt}
    newcommand*{myfbox}[1]{%
    fcolorbox{red}{red!20!white}{$#1$}%
    }
    begin{bmatrix}
    ,myfbox{B_1} & 0 & 0, \
    ,0 & myfbox{B_2} & 0, \
    ,0 & 0 & myfbox{B_3}, \
    end{bmatrix}
    ]
    end{document}



    Result with colored boxes







    share|improve this answer


























    • awesome, @Heiko. How could I get the matrix brackets to be big enough to accommodate the boxes?

      – user58865
      Sep 21 '16 at 4:45











    • @user58865 See updated answer.

      – Heiko Oberdiek
      Sep 21 '16 at 5:05
















    7














    The space between the columns is controlled by the dimen register arraycolsep:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    begin{bmatrix}
    fbox{$B_1$} & 0 & 0 \
    0 & fbox{$B_2$} & 0 \
    0 & 0 & fbox{$B_3$} \
    end{bmatrix}
    ]
    end{document}



    Result




    Without touching the delimiters:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    begin{bmatrix}
    ,fbox{$B_1$} & 0 & 0, \
    ,0 & fbox{$B_2$} & 0, \
    ,0 & 0 & fbox{$B_3$}, \
    end{bmatrix}
    ]
    end{document}



    Result




    The size of the delimiters are at least delimiterfactor per mille of the formula height or the height of the formula minus delimitershortfall. Full size is achieved by either



    delimiterfactor=1000relax



    or



    setlength{delimitershortfall}{0pt}


    Example:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    % delimiterfactor=1000 %
    setlength{delimitershortfall}{0pt}
    begin{bmatrix}
    ,fbox{$B_1$} & 0 & 0, \
    ,0 & fbox{$B_2$} & 0, \
    ,0 & 0 & fbox{$B_3$}, \
    end{bmatrix}
    ]
    end{document}



    Result




    Colored boxes would also be possible as in Zarko's answer:



    documentclass{article}
    usepackage{amsmath}
    usepackage{xcolor}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    setlength{delimitershortfall}{0pt}
    newcommand*{myfbox}[1]{%
    fcolorbox{red}{red!20!white}{$#1$}%
    }
    begin{bmatrix}
    ,myfbox{B_1} & 0 & 0, \
    ,0 & myfbox{B_2} & 0, \
    ,0 & 0 & myfbox{B_3}, \
    end{bmatrix}
    ]
    end{document}



    Result with colored boxes







    share|improve this answer


























    • awesome, @Heiko. How could I get the matrix brackets to be big enough to accommodate the boxes?

      – user58865
      Sep 21 '16 at 4:45











    • @user58865 See updated answer.

      – Heiko Oberdiek
      Sep 21 '16 at 5:05














    7












    7








    7







    The space between the columns is controlled by the dimen register arraycolsep:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    begin{bmatrix}
    fbox{$B_1$} & 0 & 0 \
    0 & fbox{$B_2$} & 0 \
    0 & 0 & fbox{$B_3$} \
    end{bmatrix}
    ]
    end{document}



    Result




    Without touching the delimiters:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    begin{bmatrix}
    ,fbox{$B_1$} & 0 & 0, \
    ,0 & fbox{$B_2$} & 0, \
    ,0 & 0 & fbox{$B_3$}, \
    end{bmatrix}
    ]
    end{document}



    Result




    The size of the delimiters are at least delimiterfactor per mille of the formula height or the height of the formula minus delimitershortfall. Full size is achieved by either



    delimiterfactor=1000relax



    or



    setlength{delimitershortfall}{0pt}


    Example:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    % delimiterfactor=1000 %
    setlength{delimitershortfall}{0pt}
    begin{bmatrix}
    ,fbox{$B_1$} & 0 & 0, \
    ,0 & fbox{$B_2$} & 0, \
    ,0 & 0 & fbox{$B_3$}, \
    end{bmatrix}
    ]
    end{document}



    Result




    Colored boxes would also be possible as in Zarko's answer:



    documentclass{article}
    usepackage{amsmath}
    usepackage{xcolor}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    setlength{delimitershortfall}{0pt}
    newcommand*{myfbox}[1]{%
    fcolorbox{red}{red!20!white}{$#1$}%
    }
    begin{bmatrix}
    ,myfbox{B_1} & 0 & 0, \
    ,0 & myfbox{B_2} & 0, \
    ,0 & 0 & myfbox{B_3}, \
    end{bmatrix}
    ]
    end{document}



    Result with colored boxes







    share|improve this answer















    The space between the columns is controlled by the dimen register arraycolsep:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    begin{bmatrix}
    fbox{$B_1$} & 0 & 0 \
    0 & fbox{$B_2$} & 0 \
    0 & 0 & fbox{$B_3$} \
    end{bmatrix}
    ]
    end{document}



    Result




    Without touching the delimiters:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    begin{bmatrix}
    ,fbox{$B_1$} & 0 & 0, \
    ,0 & fbox{$B_2$} & 0, \
    ,0 & 0 & fbox{$B_3$}, \
    end{bmatrix}
    ]
    end{document}



    Result




    The size of the delimiters are at least delimiterfactor per mille of the formula height or the height of the formula minus delimitershortfall. Full size is achieved by either



    delimiterfactor=1000relax



    or



    setlength{delimitershortfall}{0pt}


    Example:



    documentclass{article}
    usepackage{amsmath}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    % delimiterfactor=1000 %
    setlength{delimitershortfall}{0pt}
    begin{bmatrix}
    ,fbox{$B_1$} & 0 & 0, \
    ,0 & fbox{$B_2$} & 0, \
    ,0 & 0 & fbox{$B_3$}, \
    end{bmatrix}
    ]
    end{document}



    Result




    Colored boxes would also be possible as in Zarko's answer:



    documentclass{article}
    usepackage{amsmath}
    usepackage{xcolor}
    begin{document}
    [
    setlength{arraycolsep}{0pt}
    setlength{delimitershortfall}{0pt}
    newcommand*{myfbox}[1]{%
    fcolorbox{red}{red!20!white}{$#1$}%
    }
    begin{bmatrix}
    ,myfbox{B_1} & 0 & 0, \
    ,0 & myfbox{B_2} & 0, \
    ,0 & 0 & myfbox{B_3}, \
    end{bmatrix}
    ]
    end{document}



    Result with colored boxes








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 13 '17 at 12:35









    Community

    1




    1










    answered Sep 21 '16 at 4:35









    Heiko OberdiekHeiko Oberdiek

    231k19560909




    231k19560909













    • awesome, @Heiko. How could I get the matrix brackets to be big enough to accommodate the boxes?

      – user58865
      Sep 21 '16 at 4:45











    • @user58865 See updated answer.

      – Heiko Oberdiek
      Sep 21 '16 at 5:05



















    • awesome, @Heiko. How could I get the matrix brackets to be big enough to accommodate the boxes?

      – user58865
      Sep 21 '16 at 4:45











    • @user58865 See updated answer.

      – Heiko Oberdiek
      Sep 21 '16 at 5:05

















    awesome, @Heiko. How could I get the matrix brackets to be big enough to accommodate the boxes?

    – user58865
    Sep 21 '16 at 4:45





    awesome, @Heiko. How could I get the matrix brackets to be big enough to accommodate the boxes?

    – user58865
    Sep 21 '16 at 4:45













    @user58865 See updated answer.

    – Heiko Oberdiek
    Sep 21 '16 at 5:05





    @user58865 See updated answer.

    – Heiko Oberdiek
    Sep 21 '16 at 5:05











    5














    Like this?



    enter image description here



    Well, this matrix is drawn ...



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

    begin{document}
    [
    begin{tikzpicture}
    matrix (m1) [matrix of nodes,
    left delimiter={[}, right delimiter={]},
    row sep=-0.5pt,column sep=-0.5pt,
    every node/.style={inner sep=5pt}
    ]
    {
    |[draw]| $B_1$ & 0 & 0 \
    0 & |[draw]| $B_2$ & 0 \
    0 & 0 & |[draw]| $B_3$ \
    };
    end{tikzpicture}
    ]
    end{document}


    by tikz with TikZ library matrix. Distance between cells of matrix as well to its brackets are set by inner sep=5pt. Cells with "frame" have option |[draw]|.



    Addendum:
    Since the matrix is now actually image, it is simple to present on more fancy ways. For example as:



    enter image description here



    MWE for above version of matrix is:



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

    begin{document}
    [
    begin{tikzpicture}
    matrix (m1) [matrix of nodes,
    left delimiter={[}, right delimiter={]},
    row sep=-0.5pt,column sep=-0.5pt,
    every node/.style={inner sep=5pt},
    F/.style = {draw=red, line width=0.5pt, fill=red!20}
    ]
    {
    |[F]| $B_1$ & 0 & 0 \
    0 & |[F]| $B_2$ & 0 \
    0 & 0 & |[F]| $B_3$ \
    };
    end{tikzpicture}
    ]
    end{document}





    share|improve this answer






























      5














      Like this?



      enter image description here



      Well, this matrix is drawn ...



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

      begin{document}
      [
      begin{tikzpicture}
      matrix (m1) [matrix of nodes,
      left delimiter={[}, right delimiter={]},
      row sep=-0.5pt,column sep=-0.5pt,
      every node/.style={inner sep=5pt}
      ]
      {
      |[draw]| $B_1$ & 0 & 0 \
      0 & |[draw]| $B_2$ & 0 \
      0 & 0 & |[draw]| $B_3$ \
      };
      end{tikzpicture}
      ]
      end{document}


      by tikz with TikZ library matrix. Distance between cells of matrix as well to its brackets are set by inner sep=5pt. Cells with "frame" have option |[draw]|.



      Addendum:
      Since the matrix is now actually image, it is simple to present on more fancy ways. For example as:



      enter image description here



      MWE for above version of matrix is:



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

      begin{document}
      [
      begin{tikzpicture}
      matrix (m1) [matrix of nodes,
      left delimiter={[}, right delimiter={]},
      row sep=-0.5pt,column sep=-0.5pt,
      every node/.style={inner sep=5pt},
      F/.style = {draw=red, line width=0.5pt, fill=red!20}
      ]
      {
      |[F]| $B_1$ & 0 & 0 \
      0 & |[F]| $B_2$ & 0 \
      0 & 0 & |[F]| $B_3$ \
      };
      end{tikzpicture}
      ]
      end{document}





      share|improve this answer




























        5












        5








        5







        Like this?



        enter image description here



        Well, this matrix is drawn ...



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

        begin{document}
        [
        begin{tikzpicture}
        matrix (m1) [matrix of nodes,
        left delimiter={[}, right delimiter={]},
        row sep=-0.5pt,column sep=-0.5pt,
        every node/.style={inner sep=5pt}
        ]
        {
        |[draw]| $B_1$ & 0 & 0 \
        0 & |[draw]| $B_2$ & 0 \
        0 & 0 & |[draw]| $B_3$ \
        };
        end{tikzpicture}
        ]
        end{document}


        by tikz with TikZ library matrix. Distance between cells of matrix as well to its brackets are set by inner sep=5pt. Cells with "frame" have option |[draw]|.



        Addendum:
        Since the matrix is now actually image, it is simple to present on more fancy ways. For example as:



        enter image description here



        MWE for above version of matrix is:



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

        begin{document}
        [
        begin{tikzpicture}
        matrix (m1) [matrix of nodes,
        left delimiter={[}, right delimiter={]},
        row sep=-0.5pt,column sep=-0.5pt,
        every node/.style={inner sep=5pt},
        F/.style = {draw=red, line width=0.5pt, fill=red!20}
        ]
        {
        |[F]| $B_1$ & 0 & 0 \
        0 & |[F]| $B_2$ & 0 \
        0 & 0 & |[F]| $B_3$ \
        };
        end{tikzpicture}
        ]
        end{document}





        share|improve this answer















        Like this?



        enter image description here



        Well, this matrix is drawn ...



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

        begin{document}
        [
        begin{tikzpicture}
        matrix (m1) [matrix of nodes,
        left delimiter={[}, right delimiter={]},
        row sep=-0.5pt,column sep=-0.5pt,
        every node/.style={inner sep=5pt}
        ]
        {
        |[draw]| $B_1$ & 0 & 0 \
        0 & |[draw]| $B_2$ & 0 \
        0 & 0 & |[draw]| $B_3$ \
        };
        end{tikzpicture}
        ]
        end{document}


        by tikz with TikZ library matrix. Distance between cells of matrix as well to its brackets are set by inner sep=5pt. Cells with "frame" have option |[draw]|.



        Addendum:
        Since the matrix is now actually image, it is simple to present on more fancy ways. For example as:



        enter image description here



        MWE for above version of matrix is:



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

        begin{document}
        [
        begin{tikzpicture}
        matrix (m1) [matrix of nodes,
        left delimiter={[}, right delimiter={]},
        row sep=-0.5pt,column sep=-0.5pt,
        every node/.style={inner sep=5pt},
        F/.style = {draw=red, line width=0.5pt, fill=red!20}
        ]
        {
        |[F]| $B_1$ & 0 & 0 \
        0 & |[F]| $B_2$ & 0 \
        0 & 0 & |[F]| $B_3$ \
        };
        end{tikzpicture}
        ]
        end{document}






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 21 '16 at 4:51

























        answered Sep 21 '16 at 4:44









        ZarkoZarko

        127k868167




        127k868167






























            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%2f330586%2fcan-i-put-fbox-along-the-diagonal-so-that-they-touch-each-other%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

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents