3

I want to create a line inside an array (for a matrix), among which what I have created is as shown below. (I used \usepackage{hhline} and \usepackage{arydshln})

enter image description here

 \[\small{\left [\begin{array}{cc|c}
 1 & 2 &  3\\ \hhline{-|-|~}
 4 & 6 & 1\\ \hhline{~|~|-}
 -1 & -3 & 0 
\end{array}\right ]},\quad \small{\left [\begin{array}{c|c|c}
1 & 2 & 3 \\ \hhline{-|~|-}
4 & 6 & 1 \\ \hhline{-|~|-}
-1 &-3 & 0
\end{array} \right ]},\quad \small{\left [\begin{array}{c|c|c}
1 & 2 & 3 \\ \hline
4 & 6 & 1 \\ \hhline{-|~|~}
-1 &-3 & 0
\end{array} \right ]},\quad \]

But I don't know how to create a matrix with separate vertical lines as shown below. How to create vertical lines in arrays (in math mode \[...\])?

enter image description here

3
  • you can not use \small in math (and it does not have a {... argument Commented Jun 29, 2023 at 0:08
  • When I tried the resulting font size was smaller than the original, so I guess it worked. Commented Jun 29, 2023 at 14:28
  • no, you would have a warning from latex that it does not work, some constructs will change size, some will not, depending on internal implementation details Commented Jun 30, 2023 at 5:55

2 Answers 2

5

Since vertical rules in a regular tabular or array are governed by the column specification, you can identify the column specification that matches most of your layout, and adjust the nuances via \multicolumn:

enter image description here

\documentclass{article}

\begin{document}

\[
  \left(\begin{array}{ c c c | c c }
    1 & 9 & 7 & 0 & 0 \\
    2 & 4 & 5 & 0 & 0 \\
    \hline
    0 & 0 & \multicolumn{1}{| c }{0} & 3 & 3
  \end{array}\right)
\]

\end{document}
3

It may well be an overkill for this very task but nicematrix can be used for this and more advanced tasks.

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

\[\begin{pNiceMatrix}
    1  & 9  & 7  & 0  & 0 \\ 
    2 & 4 & 5 & 0 & 0\\
    0 & 0 & 0 & 3 & 3
\CodeAfter
\begin{tikzpicture}
    \draw (3-|1) -- (3-|6)  (3-|3) -- (4-|3) (3-|4) -- (1-|4);
\end{tikzpicture}
\end{pNiceMatrix}
\]
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .