How to draw a nice diagonal matrix? Announcing the arrival of Valued Associate #679: Cesar...

What does "lightly crushed" mean for cardamon pods?

What is homebrew?

Is the Standard Deduction better than Itemized when both are the same amount?

How to answer "Have you ever been terminated?"

How come Sam didn't become Lord of Horn Hill?

What causes the direction of lightning flashes?

Circuit to "zoom in" on mV fluctuations of a DC signal?

How does the math work when buying airline miles?

What is the meaning of the simile “quick as silk”?

Irreducible of finite Krull dimension implies quasi-compact?

How could we fake a moon landing now?

Amount of permutations on an NxNxN Rubik's Cube

Wu formula for manifolds with boundary

Why are there no cargo aircraft with "flying wing" design?

Is there a kind of relay only consumes power when switching?

Around usage results

Using et al. for a last / senior author rather than for a first author

An adverb for when you're not exaggerating

If my PI received research grants from a company to be able to pay my postdoc salary, did I have a potential conflict interest too?

When the Haste spell ends on a creature, do attackers have advantage against that creature?

Is it a good idea to use CNN to classify 1D signal?

Using audio cues to encourage good posture

Most bit efficient text communication method?

Is CEO the profession with the most psychopaths?



How to draw a nice diagonal matrix?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)diagonal line within matrixDiagonal text in diagonal matrixHow to create diagonal matrix with an aligned diagonal?Coloring the diagonal of a matrixHow to draw this special matrix with two diagonal braces?Typesetting a band diagonal matrixband diagonal MatrixDraw a matrix partitioned into upper, lower, and diagonal partsHow to create the following diagonal matrix in Latex?How to draw a diagonal slash through an entire matrix in LaTeX?












5















How to typeset a nice looking diagonal matrix? I find myself, once again, fiddling with phantoms and running raiseboxes to get an aesthetic result. This kind of micromanagement is bad practice, but why does the default look so bad and is there a better way? Two diagonal matrices side by side



documentclass{article}
usepackage{mathtools}
begin{document}

begin{align*}
operatorname{diag} x &=
begin{bmatrix}
x_1 & 0 & 0\
0 & ddots & 0 \
0 & 0 & x_n
end{bmatrix}
&
operatorname{diag} x &=
begin{bmatrix}
x_1 & 0 & 0\
0 & raisebox{-0.4ex}{(ddots)}rule[3.4ex]{0pt}{0pt} & 0 \
0 & 0 & x_n rule[3.4ex]{0pt}{0pt}
end{bmatrix}
end{align*}

end{document}









share|improve this question























  • First, use DeclareMathOperator if you use "diag" many times in the document.

    – JouleV
    15 hours ago






  • 1





    Hmm, the problem is not with bmatrix, but with ddots.

    – JouleV
    15 hours ago











  • defarraystretch{1.5}% outside align or inside equation

    – John Kormylo
    11 hours ago
















5















How to typeset a nice looking diagonal matrix? I find myself, once again, fiddling with phantoms and running raiseboxes to get an aesthetic result. This kind of micromanagement is bad practice, but why does the default look so bad and is there a better way? Two diagonal matrices side by side



documentclass{article}
usepackage{mathtools}
begin{document}

begin{align*}
operatorname{diag} x &=
begin{bmatrix}
x_1 & 0 & 0\
0 & ddots & 0 \
0 & 0 & x_n
end{bmatrix}
&
operatorname{diag} x &=
begin{bmatrix}
x_1 & 0 & 0\
0 & raisebox{-0.4ex}{(ddots)}rule[3.4ex]{0pt}{0pt} & 0 \
0 & 0 & x_n rule[3.4ex]{0pt}{0pt}
end{bmatrix}
end{align*}

end{document}









share|improve this question























  • First, use DeclareMathOperator if you use "diag" many times in the document.

    – JouleV
    15 hours ago






  • 1





    Hmm, the problem is not with bmatrix, but with ddots.

    – JouleV
    15 hours ago











  • defarraystretch{1.5}% outside align or inside equation

    – John Kormylo
    11 hours ago














5












5








5


0






How to typeset a nice looking diagonal matrix? I find myself, once again, fiddling with phantoms and running raiseboxes to get an aesthetic result. This kind of micromanagement is bad practice, but why does the default look so bad and is there a better way? Two diagonal matrices side by side



documentclass{article}
usepackage{mathtools}
begin{document}

begin{align*}
operatorname{diag} x &=
begin{bmatrix}
x_1 & 0 & 0\
0 & ddots & 0 \
0 & 0 & x_n
end{bmatrix}
&
operatorname{diag} x &=
begin{bmatrix}
x_1 & 0 & 0\
0 & raisebox{-0.4ex}{(ddots)}rule[3.4ex]{0pt}{0pt} & 0 \
0 & 0 & x_n rule[3.4ex]{0pt}{0pt}
end{bmatrix}
end{align*}

end{document}









share|improve this question














How to typeset a nice looking diagonal matrix? I find myself, once again, fiddling with phantoms and running raiseboxes to get an aesthetic result. This kind of micromanagement is bad practice, but why does the default look so bad and is there a better way? Two diagonal matrices side by side



documentclass{article}
usepackage{mathtools}
begin{document}

begin{align*}
operatorname{diag} x &=
begin{bmatrix}
x_1 & 0 & 0\
0 & ddots & 0 \
0 & 0 & x_n
end{bmatrix}
&
operatorname{diag} x &=
begin{bmatrix}
x_1 & 0 & 0\
0 & raisebox{-0.4ex}{(ddots)}rule[3.4ex]{0pt}{0pt} & 0 \
0 & 0 & x_n rule[3.4ex]{0pt}{0pt}
end{bmatrix}
end{align*}

end{document}






matrices






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 15 hours ago









MankkaMankka

24728




24728













  • First, use DeclareMathOperator if you use "diag" many times in the document.

    – JouleV
    15 hours ago






  • 1





    Hmm, the problem is not with bmatrix, but with ddots.

    – JouleV
    15 hours ago











  • defarraystretch{1.5}% outside align or inside equation

    – John Kormylo
    11 hours ago



















  • First, use DeclareMathOperator if you use "diag" many times in the document.

    – JouleV
    15 hours ago






  • 1





    Hmm, the problem is not with bmatrix, but with ddots.

    – JouleV
    15 hours ago











  • defarraystretch{1.5}% outside align or inside equation

    – John Kormylo
    11 hours ago

















First, use DeclareMathOperator if you use "diag" many times in the document.

– JouleV
15 hours ago





First, use DeclareMathOperator if you use "diag" many times in the document.

– JouleV
15 hours ago




1




1





Hmm, the problem is not with bmatrix, but with ddots.

– JouleV
15 hours ago





Hmm, the problem is not with bmatrix, but with ddots.

– JouleV
15 hours ago













defarraystretch{1.5}% outside align or inside equation

– John Kormylo
11 hours ago





defarraystretch{1.5}% outside align or inside equation

– John Kormylo
11 hours ago










1 Answer
1






active

oldest

votes


















5














A TABstack alternative.



documentclass{article}
usepackage{mathtools,tabstackengine}
TABstackMath% STACK MATRIX IN MATH MODE
setstacktabbedgap{10pt}% INTER-COLUMN GAP SIZE
setstackgap{L}{1.5baselineskip}% INTER-ROW BASELINESKIP
newcommandcddots{raisebox{-1pt}{$ddots$}}
begin{document}
[ operatorname{diag} x =
bracketMatrixstack{
x_1 & 0 & 0\
0 & cddots & 0 \
0 & 0 & x_n
}
]
end{document}


enter image description here



While not needed for diagonal matrices of the type portrayed by the OP, the package has a fixTABwidth{<T or F>} declaration to fix all column widths to the largest found in the matrix. That can be helpful if there are wide matrix entries:



documentclass{article}
usepackage{mathtools,tabstackengine}
TABstackMath% STACK MATRIX IN MATH MODE
setstacktabbedgap{10pt}% INTER-COLUMN GAP SIZE
setstackgap{L}{1.5baselineskip}% INTER-ROW BASELINESKIP
newcommandcddots{raisebox{-1pt}{$ddots$}}
begin{document}
fixTABwidth{T}
[ operatorname{diag} x =
bracketMatrixstack{
x_1 & 0 & 12345\
0 & cddots & 0 \
0 & 0 & x_n
}
]
end{document}


enter image description here






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%2f485276%2fhow-to-draw-a-nice-diagonal-matrix%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    A TABstack alternative.



    documentclass{article}
    usepackage{mathtools,tabstackengine}
    TABstackMath% STACK MATRIX IN MATH MODE
    setstacktabbedgap{10pt}% INTER-COLUMN GAP SIZE
    setstackgap{L}{1.5baselineskip}% INTER-ROW BASELINESKIP
    newcommandcddots{raisebox{-1pt}{$ddots$}}
    begin{document}
    [ operatorname{diag} x =
    bracketMatrixstack{
    x_1 & 0 & 0\
    0 & cddots & 0 \
    0 & 0 & x_n
    }
    ]
    end{document}


    enter image description here



    While not needed for diagonal matrices of the type portrayed by the OP, the package has a fixTABwidth{<T or F>} declaration to fix all column widths to the largest found in the matrix. That can be helpful if there are wide matrix entries:



    documentclass{article}
    usepackage{mathtools,tabstackengine}
    TABstackMath% STACK MATRIX IN MATH MODE
    setstacktabbedgap{10pt}% INTER-COLUMN GAP SIZE
    setstackgap{L}{1.5baselineskip}% INTER-ROW BASELINESKIP
    newcommandcddots{raisebox{-1pt}{$ddots$}}
    begin{document}
    fixTABwidth{T}
    [ operatorname{diag} x =
    bracketMatrixstack{
    x_1 & 0 & 12345\
    0 & cddots & 0 \
    0 & 0 & x_n
    }
    ]
    end{document}


    enter image description here






    share|improve this answer




























      5














      A TABstack alternative.



      documentclass{article}
      usepackage{mathtools,tabstackengine}
      TABstackMath% STACK MATRIX IN MATH MODE
      setstacktabbedgap{10pt}% INTER-COLUMN GAP SIZE
      setstackgap{L}{1.5baselineskip}% INTER-ROW BASELINESKIP
      newcommandcddots{raisebox{-1pt}{$ddots$}}
      begin{document}
      [ operatorname{diag} x =
      bracketMatrixstack{
      x_1 & 0 & 0\
      0 & cddots & 0 \
      0 & 0 & x_n
      }
      ]
      end{document}


      enter image description here



      While not needed for diagonal matrices of the type portrayed by the OP, the package has a fixTABwidth{<T or F>} declaration to fix all column widths to the largest found in the matrix. That can be helpful if there are wide matrix entries:



      documentclass{article}
      usepackage{mathtools,tabstackengine}
      TABstackMath% STACK MATRIX IN MATH MODE
      setstacktabbedgap{10pt}% INTER-COLUMN GAP SIZE
      setstackgap{L}{1.5baselineskip}% INTER-ROW BASELINESKIP
      newcommandcddots{raisebox{-1pt}{$ddots$}}
      begin{document}
      fixTABwidth{T}
      [ operatorname{diag} x =
      bracketMatrixstack{
      x_1 & 0 & 12345\
      0 & cddots & 0 \
      0 & 0 & x_n
      }
      ]
      end{document}


      enter image description here






      share|improve this answer


























        5












        5








        5







        A TABstack alternative.



        documentclass{article}
        usepackage{mathtools,tabstackengine}
        TABstackMath% STACK MATRIX IN MATH MODE
        setstacktabbedgap{10pt}% INTER-COLUMN GAP SIZE
        setstackgap{L}{1.5baselineskip}% INTER-ROW BASELINESKIP
        newcommandcddots{raisebox{-1pt}{$ddots$}}
        begin{document}
        [ operatorname{diag} x =
        bracketMatrixstack{
        x_1 & 0 & 0\
        0 & cddots & 0 \
        0 & 0 & x_n
        }
        ]
        end{document}


        enter image description here



        While not needed for diagonal matrices of the type portrayed by the OP, the package has a fixTABwidth{<T or F>} declaration to fix all column widths to the largest found in the matrix. That can be helpful if there are wide matrix entries:



        documentclass{article}
        usepackage{mathtools,tabstackengine}
        TABstackMath% STACK MATRIX IN MATH MODE
        setstacktabbedgap{10pt}% INTER-COLUMN GAP SIZE
        setstackgap{L}{1.5baselineskip}% INTER-ROW BASELINESKIP
        newcommandcddots{raisebox{-1pt}{$ddots$}}
        begin{document}
        fixTABwidth{T}
        [ operatorname{diag} x =
        bracketMatrixstack{
        x_1 & 0 & 12345\
        0 & cddots & 0 \
        0 & 0 & x_n
        }
        ]
        end{document}


        enter image description here






        share|improve this answer













        A TABstack alternative.



        documentclass{article}
        usepackage{mathtools,tabstackengine}
        TABstackMath% STACK MATRIX IN MATH MODE
        setstacktabbedgap{10pt}% INTER-COLUMN GAP SIZE
        setstackgap{L}{1.5baselineskip}% INTER-ROW BASELINESKIP
        newcommandcddots{raisebox{-1pt}{$ddots$}}
        begin{document}
        [ operatorname{diag} x =
        bracketMatrixstack{
        x_1 & 0 & 0\
        0 & cddots & 0 \
        0 & 0 & x_n
        }
        ]
        end{document}


        enter image description here



        While not needed for diagonal matrices of the type portrayed by the OP, the package has a fixTABwidth{<T or F>} declaration to fix all column widths to the largest found in the matrix. That can be helpful if there are wide matrix entries:



        documentclass{article}
        usepackage{mathtools,tabstackengine}
        TABstackMath% STACK MATRIX IN MATH MODE
        setstacktabbedgap{10pt}% INTER-COLUMN GAP SIZE
        setstackgap{L}{1.5baselineskip}% INTER-ROW BASELINESKIP
        newcommandcddots{raisebox{-1pt}{$ddots$}}
        begin{document}
        fixTABwidth{T}
        [ operatorname{diag} x =
        bracketMatrixstack{
        x_1 & 0 & 12345\
        0 & cddots & 0 \
        0 & 0 & x_n
        }
        ]
        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 15 hours ago









        Steven B. SegletesSteven B. Segletes

        162k9206418




        162k9206418






























            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%2f485276%2fhow-to-draw-a-nice-diagonal-matrix%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

            Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

            Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...