I tried to type an equation below in Overleaf. Please help me with how I could type it.
Thank you all,
Math & Science ⇒ How to type complexity equation in overleaf
-
- Posts: 1
- Joined: Tue Jun 27, 2023 4:18 am
How to type complexity equation in overleaf
- Attachments
-
- Capture.PNG (30.47 KiB) Viewed 10231 times
How to type complexity equation in overleaf
Hello!
You need use
https://ctan.org/pkg/nicematrix
Unfortunatelly, I'm not LaTeX professional, so this is the best I can do, sorry.

The main problem of my solution is that left exterior column is right aligned. According nicematrix documentation this is by design (page 24 on pdf documentation). In footnote 35 on this page I read that we need to use
AGSH
You need use
nicematrix
package. It definitelly can do such matrices.https://ctan.org/pkg/nicematrix
Unfortunatelly, I'm not LaTeX professional, so this is the best I can do, sorry.
Code: Select all
\documentclass{article}
\usepackage{tikz}
\usepackage{nicematrix}
\begin{document}
$$
\begin{pNiceArray}{ccccccccc}[first-row,first-col]
& n + 1 & \cdots & n + m & 1 & \cdots & m & m +1 & \cdots & n \\
{n + 1}& \Block[borders={bottom, right, tikz={dashed}}]{3-3}{\vec a} & & &
\Block[borders={bottom, right, tikz={dashed}}]{3-3}{\vec b} & & &
\Block[borders={bottom, tikz={dashed}}]{3-3}{\vec c} & & \\
{\Vdots} & & & & & & & & & \\
{n + m} & & & & & & & & & \\
{1} & \Block[borders={bottom, right, tikz={dashed}}]{3-3}{\vec x} & & & \Block{6-6}{\vec a} & & & & & \\
{\Vdots} & & & & & & & & & \\
{m} & & & & & & & & & \\
{m + 1} & \Block[borders={right, tikz={dashed}}]{3-3}{\vec y} & & & & & & & & \\
{\Vdots} & & & & & & & & & \\
{n} & & & & & & & & & \\
\end{pNiceArray}
$$
\end{document}

The main problem of my solution is that left exterior column is right aligned. According nicematrix documentation this is by design (page 24 on pdf documentation). In footnote 35 on this page I read that we need to use
\CodeAfter
and \Submatrix
to make left exterior column be centering or to have other alignment. I tried this without success. The error is about the last column is empty, and I have no idea how to solve this. Of course there is an email of package author on the top of nicematrix documentation...AGSH
How to type complexity equation in overleaf
Here is a solution with
nicematrix
and the first column left-aligned (by using the command \SubMatrix
in the so-called \CodeAfter
.Code: Select all
\documentclass{article}
\usepackage{tikz}
\usepackage{nicematrix}
\begin{document}
\[
\begin{NiceArray}{lccccccccc}[first-row]
& n + 1 & \cdots & n + m & 1 & \cdots & m & m +1 & \cdots & n \\
n + 1& \Block[borders={bottom, right, tikz=dashed}]{3-3}{\vec{a}} & & &
\Block[borders={bottom, right, tikz=dashed}]{3-3}{\vec{b}} & & &
\Block[borders={bottom, tikz=dashed}]{3-3}{\vec{c}} & & \\
\vdots & & & & & & & & & \\
n + m & & & & & & & & & \\
1 & \Block[borders={bottom, right, tikz=dashed}]{3-3}{\vec{x}} & & & \Block{6-6}{\vec{a}} & & & & & \\
\vdots & & & & & & & & & \\
m & & & & & & & & & \\
m + 1 & \Block[borders={right, tikz=dashed}]{3-3}{\vec{y}} & & & & & & & & \\
\vdots & & & & & & & & & \\
n & & & & & & & & & \\
\CodeAfter
\SubMatrix({1-2}{9-10})
\end{NiceArray}
\]
\end{document}