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
Thank you all,
- Attachments
-
- Capture.PNG (30.47 KiB) Viewed 20678 times
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
How to type complexity equation in overleaf
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
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}