3

So I am using the package nicematrix to write a matrix with unlimited entries, but the ddots on the middle and lower right are not aligned with each other. Is there a way to achieve this?

This is my code:

\begin{pNiceMatrix}
        C_{0m}C_{0m}&C_{0m}C_{1m} & \cdots \\
        C_{1m}C_{0m}&\ddots &\\
        \vdots& &\ddots\\
\end{pNiceMatrix}

enter image description here

0

3 Answers 3

10

How about this? enter image description here

\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\[
\renewcommand{\arraystretch}{2.25} % <---                                       
\begin{pNiceMatrix}
C_{0m}C_{0m}& C_{0m}C_{1m} & \cdots \\
C_{1m}C_{0m}&   \ddots     & \\
\vdots      &              & \ddots
\end{pNiceMatrix}
\]
\end{document}
2
  • 3
    Sneaky but effective. The key is making the cells essentially square. One might complain that the dots in the middle are too high, not vertically aligned on the math axis, but trying to achieve that would only make the problem more difficult and the result more space-gobbling. Well done. Jul 24, 2021 at 20:29
  • 1
    @barbarabeeton, Good to have your comments!
    – citsahcots
    Jul 24, 2021 at 21:26
3

We should use \Cdots, \Vdots, \Ddots (unless you use the option renew-dots).

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

$\begin{pNiceMatrix}[extra-margin=2mm]
C_{0m}C_{0m}  &C_{0m}C_{1m} & \Cdots \\
C_{1m}C_{0m}  &\Ddots      &        \\
\Vdots       &            & \hspace*{5mm}\\
\end{pNiceMatrix}$

\end{document}

I have put \hspace*{5mm} in the last cell to have a non empty-cell (nicematrix does not like empty cells).

enter image description here

2
  • 1
    Doesn’t look particularly pretty to me. I especially don’t like the position of the diagonal dots or their end position.
    – Gaussler
    Jul 24, 2021 at 13:07
  • 2
    @Gaussler: In fact, I think that such matrix is not good mathematical design. I think one should put at least the content of the four corners of the matrix. Jul 24, 2021 at 13:11
3

To draw a nice dotted diagonal, from the bottom center of cell to the top center of the other, using nicematrix you need to do two things:

(1) Fill the cell with some content (invisible). I choose \phantom{\cdots} because you may want to show cdots after all.

(2) Use \CodeAfter to draw the dotted diagonal.

A

\documentclass{article}
\usepackage{nicematrix}
\begin{document}

    \begin{align*}                                    
    \begin{pNiceMatrix}
        C_{0m}C_{0m}& C_{0m}C_{1m} & \cdots \\
        C_{1m}C_{0m}& \phantom{\cdots}    &  \\
        \vdots      &             & \phantom{\cdots}\\
        \CodeAfter  % added <<<<<<<<<<<<
        \line{2-2}{3-3}
    \end{pNiceMatrix}
\end{align*}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.