How to draw a nice diagonal matrix?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?Draw 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?

Is the text of all UK treaties and laws public?

に vs. を in "to pass a test"

This fell out of my toilet when I unscrewed the supply line. What is it?

Was Wayne Brady considered a guest star on the original "Whose Line Is It Anyway?"

Why didn't Snape ask Dumbledore why he let "Moody" search his office?

Creating chess engine, machine learning vs. traditional engine?

Should I withdraw my paper because the Editor is behaving so badly with me?

In 1700s, why was 'books that never read' grammatical?

Does "Op. cit." stand for "opus citatum" or "opere citato"?

What are the bars protruding from this C-130?

Rat proofing compost bin but allowing worms in

How to handle motorists' dangerous behaviour with an impassable group?

one-liner vs script

How can I remove rest of file from string for all files?

Why did a young George Washington sign a document admitting to assassinating a French military officer?

How long could a human survive completely without the immune system?

Would we have more than 8 minutes of light, if the sun "went out"?

Can massive damage kill you while at 0 HP?

Iron-age tools, is there a way to extract heavy metals out of a creature?

Is there a magnetic attraction between two parallel electron beams?

Which accidental continues through the bar?

3x3 self-descriptive squares

My first random password generator

Can a Dragon enter the feywild at will?



How to draw a nice diagonal matrix?


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?Draw 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?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









6















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



documentclassarticle
usepackagemathtools
begindocument

beginalign*
operatornamediag x &=
beginbmatrix
x_1 & 0 & 0\
0 & ddots & 0 \
0 & 0 & x_n
endbmatrix
&
operatornamediag x &=
beginbmatrix
x_1 & 0 & 0\
0 & raisebox-0.4ex(ddots)rule[3.4ex]0pt0pt & 0 \
0 & 0 & x_n rule[3.4ex]0pt0pt
endbmatrix
endalign*

enddocument









share|improve this question
























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

    – user156344
    Apr 17 at 11:34






  • 1





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

    – user156344
    Apr 17 at 11:39











  • defarraystretch1.5% outside align or inside equation

    – John Kormylo
    Apr 17 at 15:17

















6















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



documentclassarticle
usepackagemathtools
begindocument

beginalign*
operatornamediag x &=
beginbmatrix
x_1 & 0 & 0\
0 & ddots & 0 \
0 & 0 & x_n
endbmatrix
&
operatornamediag x &=
beginbmatrix
x_1 & 0 & 0\
0 & raisebox-0.4ex(ddots)rule[3.4ex]0pt0pt & 0 \
0 & 0 & x_n rule[3.4ex]0pt0pt
endbmatrix
endalign*

enddocument









share|improve this question
























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

    – user156344
    Apr 17 at 11:34






  • 1





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

    – user156344
    Apr 17 at 11:39











  • defarraystretch1.5% outside align or inside equation

    – John Kormylo
    Apr 17 at 15:17













6












6








6


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



documentclassarticle
usepackagemathtools
begindocument

beginalign*
operatornamediag x &=
beginbmatrix
x_1 & 0 & 0\
0 & ddots & 0 \
0 & 0 & x_n
endbmatrix
&
operatornamediag x &=
beginbmatrix
x_1 & 0 & 0\
0 & raisebox-0.4ex(ddots)rule[3.4ex]0pt0pt & 0 \
0 & 0 & x_n rule[3.4ex]0pt0pt
endbmatrix
endalign*

enddocument









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



documentclassarticle
usepackagemathtools
begindocument

beginalign*
operatornamediag x &=
beginbmatrix
x_1 & 0 & 0\
0 & ddots & 0 \
0 & 0 & x_n
endbmatrix
&
operatornamediag x &=
beginbmatrix
x_1 & 0 & 0\
0 & raisebox-0.4ex(ddots)rule[3.4ex]0pt0pt & 0 \
0 & 0 & x_n rule[3.4ex]0pt0pt
endbmatrix
endalign*

enddocument






matrices






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 17 at 11:33









MankkaMankka

2522 silver badges9 bronze badges




2522 silver badges9 bronze badges















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

    – user156344
    Apr 17 at 11:34






  • 1





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

    – user156344
    Apr 17 at 11:39











  • defarraystretch1.5% outside align or inside equation

    – John Kormylo
    Apr 17 at 15:17

















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

    – user156344
    Apr 17 at 11:34






  • 1





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

    – user156344
    Apr 17 at 11:39











  • defarraystretch1.5% outside align or inside equation

    – John Kormylo
    Apr 17 at 15:17
















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

– user156344
Apr 17 at 11:34





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

– user156344
Apr 17 at 11:34




1




1





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

– user156344
Apr 17 at 11:39





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

– user156344
Apr 17 at 11:39













defarraystretch1.5% outside align or inside equation

– John Kormylo
Apr 17 at 15:17





defarraystretch1.5% outside align or inside equation

– John Kormylo
Apr 17 at 15:17










2 Answers
2






active

oldest

votes


















6
















A TABstack alternative.



documentclassarticle
usepackagemathtools,tabstackengine
TABstackMath% STACK MATRIX IN MATH MODE
setstacktabbedgap10pt% INTER-COLUMN GAP SIZE
setstackgapL1.5baselineskip% INTER-ROW BASELINESKIP
newcommandcddotsraisebox-1pt$ddots$
begindocument
[ operatornamediag x =
bracketMatrixstack
x_1 & 0 & 0\
0 & cddots & 0 \
0 & 0 & x_n

]
enddocument


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:



documentclassarticle
usepackagemathtools,tabstackengine
TABstackMath% STACK MATRIX IN MATH MODE
setstacktabbedgap10pt% INTER-COLUMN GAP SIZE
setstackgapL1.5baselineskip% INTER-ROW BASELINESKIP
newcommandcddotsraisebox-1pt$ddots$
begindocument
fixTABwidthT
[ operatornamediag x =
bracketMatrixstack
x_1 & 0 & 12345\
0 & cddots & 0 \
0 & 0 & x_n

]
enddocument


enter image description here






share|improve this answer
































    3
















    You could if you liked to use the package nicematrix. Between the many options defined by nicematrix there is columns-width, where you can fit the two brackets of the matrix in function of the values into it.



    enter image description here



    documentclassarticle
    usepackagemathtools
    usepackagenicematrix
    NiceMatrixOptionstransparent,nullify-dots
    begindocument
    [operatornamediag x =beginbmatrix[columns-width = 3mm]
    x_1 & 0 & 0\
    0 & ddots & 0 \
    0 & 0 & x_n
    endbmatrix]
    enddocument


    Another possibility using columns-width = auto:



    enter image description here



    documentclassarticle
    usepackagemathtools
    usepackagenicematrix
    NiceMatrixOptionstransparent,nullify-dots
    begindocument


    [operatornamediag x =beginbmatrix[columns-width = auto]
    x_1 & 436436 & 67676\
    0 & ddots & 0 \
    8778 & 0 & x_n
    endbmatrix]


    enddocument





    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/4.0/"u003ecc by-sa 4.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

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      6
















      A TABstack alternative.



      documentclassarticle
      usepackagemathtools,tabstackengine
      TABstackMath% STACK MATRIX IN MATH MODE
      setstacktabbedgap10pt% INTER-COLUMN GAP SIZE
      setstackgapL1.5baselineskip% INTER-ROW BASELINESKIP
      newcommandcddotsraisebox-1pt$ddots$
      begindocument
      [ operatornamediag x =
      bracketMatrixstack
      x_1 & 0 & 0\
      0 & cddots & 0 \
      0 & 0 & x_n

      ]
      enddocument


      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:



      documentclassarticle
      usepackagemathtools,tabstackengine
      TABstackMath% STACK MATRIX IN MATH MODE
      setstacktabbedgap10pt% INTER-COLUMN GAP SIZE
      setstackgapL1.5baselineskip% INTER-ROW BASELINESKIP
      newcommandcddotsraisebox-1pt$ddots$
      begindocument
      fixTABwidthT
      [ operatornamediag x =
      bracketMatrixstack
      x_1 & 0 & 12345\
      0 & cddots & 0 \
      0 & 0 & x_n

      ]
      enddocument


      enter image description here






      share|improve this answer





























        6
















        A TABstack alternative.



        documentclassarticle
        usepackagemathtools,tabstackengine
        TABstackMath% STACK MATRIX IN MATH MODE
        setstacktabbedgap10pt% INTER-COLUMN GAP SIZE
        setstackgapL1.5baselineskip% INTER-ROW BASELINESKIP
        newcommandcddotsraisebox-1pt$ddots$
        begindocument
        [ operatornamediag x =
        bracketMatrixstack
        x_1 & 0 & 0\
        0 & cddots & 0 \
        0 & 0 & x_n

        ]
        enddocument


        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:



        documentclassarticle
        usepackagemathtools,tabstackengine
        TABstackMath% STACK MATRIX IN MATH MODE
        setstacktabbedgap10pt% INTER-COLUMN GAP SIZE
        setstackgapL1.5baselineskip% INTER-ROW BASELINESKIP
        newcommandcddotsraisebox-1pt$ddots$
        begindocument
        fixTABwidthT
        [ operatornamediag x =
        bracketMatrixstack
        x_1 & 0 & 12345\
        0 & cddots & 0 \
        0 & 0 & x_n

        ]
        enddocument


        enter image description here






        share|improve this answer



























          6














          6










          6









          A TABstack alternative.



          documentclassarticle
          usepackagemathtools,tabstackengine
          TABstackMath% STACK MATRIX IN MATH MODE
          setstacktabbedgap10pt% INTER-COLUMN GAP SIZE
          setstackgapL1.5baselineskip% INTER-ROW BASELINESKIP
          newcommandcddotsraisebox-1pt$ddots$
          begindocument
          [ operatornamediag x =
          bracketMatrixstack
          x_1 & 0 & 0\
          0 & cddots & 0 \
          0 & 0 & x_n

          ]
          enddocument


          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:



          documentclassarticle
          usepackagemathtools,tabstackengine
          TABstackMath% STACK MATRIX IN MATH MODE
          setstacktabbedgap10pt% INTER-COLUMN GAP SIZE
          setstackgapL1.5baselineskip% INTER-ROW BASELINESKIP
          newcommandcddotsraisebox-1pt$ddots$
          begindocument
          fixTABwidthT
          [ operatornamediag x =
          bracketMatrixstack
          x_1 & 0 & 12345\
          0 & cddots & 0 \
          0 & 0 & x_n

          ]
          enddocument


          enter image description here






          share|improve this answer













          A TABstack alternative.



          documentclassarticle
          usepackagemathtools,tabstackengine
          TABstackMath% STACK MATRIX IN MATH MODE
          setstacktabbedgap10pt% INTER-COLUMN GAP SIZE
          setstackgapL1.5baselineskip% INTER-ROW BASELINESKIP
          newcommandcddotsraisebox-1pt$ddots$
          begindocument
          [ operatornamediag x =
          bracketMatrixstack
          x_1 & 0 & 0\
          0 & cddots & 0 \
          0 & 0 & x_n

          ]
          enddocument


          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:



          documentclassarticle
          usepackagemathtools,tabstackengine
          TABstackMath% STACK MATRIX IN MATH MODE
          setstacktabbedgap10pt% INTER-COLUMN GAP SIZE
          setstackgapL1.5baselineskip% INTER-ROW BASELINESKIP
          newcommandcddotsraisebox-1pt$ddots$
          begindocument
          fixTABwidthT
          [ operatornamediag x =
          bracketMatrixstack
          x_1 & 0 & 12345\
          0 & cddots & 0 \
          0 & 0 & x_n

          ]
          enddocument


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 17 at 11:55









          Steven B. SegletesSteven B. Segletes

          171k9 gold badges216 silver badges444 bronze badges




          171k9 gold badges216 silver badges444 bronze badges


























              3
















              You could if you liked to use the package nicematrix. Between the many options defined by nicematrix there is columns-width, where you can fit the two brackets of the matrix in function of the values into it.



              enter image description here



              documentclassarticle
              usepackagemathtools
              usepackagenicematrix
              NiceMatrixOptionstransparent,nullify-dots
              begindocument
              [operatornamediag x =beginbmatrix[columns-width = 3mm]
              x_1 & 0 & 0\
              0 & ddots & 0 \
              0 & 0 & x_n
              endbmatrix]
              enddocument


              Another possibility using columns-width = auto:



              enter image description here



              documentclassarticle
              usepackagemathtools
              usepackagenicematrix
              NiceMatrixOptionstransparent,nullify-dots
              begindocument


              [operatornamediag x =beginbmatrix[columns-width = auto]
              x_1 & 436436 & 67676\
              0 & ddots & 0 \
              8778 & 0 & x_n
              endbmatrix]


              enddocument





              share|improve this answer





























                3
















                You could if you liked to use the package nicematrix. Between the many options defined by nicematrix there is columns-width, where you can fit the two brackets of the matrix in function of the values into it.



                enter image description here



                documentclassarticle
                usepackagemathtools
                usepackagenicematrix
                NiceMatrixOptionstransparent,nullify-dots
                begindocument
                [operatornamediag x =beginbmatrix[columns-width = 3mm]
                x_1 & 0 & 0\
                0 & ddots & 0 \
                0 & 0 & x_n
                endbmatrix]
                enddocument


                Another possibility using columns-width = auto:



                enter image description here



                documentclassarticle
                usepackagemathtools
                usepackagenicematrix
                NiceMatrixOptionstransparent,nullify-dots
                begindocument


                [operatornamediag x =beginbmatrix[columns-width = auto]
                x_1 & 436436 & 67676\
                0 & ddots & 0 \
                8778 & 0 & x_n
                endbmatrix]


                enddocument





                share|improve this answer



























                  3














                  3










                  3









                  You could if you liked to use the package nicematrix. Between the many options defined by nicematrix there is columns-width, where you can fit the two brackets of the matrix in function of the values into it.



                  enter image description here



                  documentclassarticle
                  usepackagemathtools
                  usepackagenicematrix
                  NiceMatrixOptionstransparent,nullify-dots
                  begindocument
                  [operatornamediag x =beginbmatrix[columns-width = 3mm]
                  x_1 & 0 & 0\
                  0 & ddots & 0 \
                  0 & 0 & x_n
                  endbmatrix]
                  enddocument


                  Another possibility using columns-width = auto:



                  enter image description here



                  documentclassarticle
                  usepackagemathtools
                  usepackagenicematrix
                  NiceMatrixOptionstransparent,nullify-dots
                  begindocument


                  [operatornamediag x =beginbmatrix[columns-width = auto]
                  x_1 & 436436 & 67676\
                  0 & ddots & 0 \
                  8778 & 0 & x_n
                  endbmatrix]


                  enddocument





                  share|improve this answer













                  You could if you liked to use the package nicematrix. Between the many options defined by nicematrix there is columns-width, where you can fit the two brackets of the matrix in function of the values into it.



                  enter image description here



                  documentclassarticle
                  usepackagemathtools
                  usepackagenicematrix
                  NiceMatrixOptionstransparent,nullify-dots
                  begindocument
                  [operatornamediag x =beginbmatrix[columns-width = 3mm]
                  x_1 & 0 & 0\
                  0 & ddots & 0 \
                  0 & 0 & x_n
                  endbmatrix]
                  enddocument


                  Another possibility using columns-width = auto:



                  enter image description here



                  documentclassarticle
                  usepackagemathtools
                  usepackagenicematrix
                  NiceMatrixOptionstransparent,nullify-dots
                  begindocument


                  [operatornamediag x =beginbmatrix[columns-width = auto]
                  x_1 & 436436 & 67676\
                  0 & ddots & 0 \
                  8778 & 0 & x_n
                  endbmatrix]


                  enddocument






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 2 at 8:41









                  SebastianoSebastiano

                  16.4k5 gold badges27 silver badges82 bronze badges




                  16.4k5 gold badges27 silver badges82 bronze badges































                      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

                      Tamil (spriik) Luke uk diar | Nawigatjuun

                      Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                      Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?