4

Is it possible for me to insert a vertical dotted line between the last two columns?

enter image description here

\begin{pmatrix}
  1  & -1 &  0 &  0 & \cdots & 0 & a_1 \\
  0  &  1 & -1 &  0 & \cdots & 0 & a_2 \\
  0  &  0 &  1 & -1 & \cdots & 0 & a_3 \\
  \vdots  & \vdots  & \vdots & \vdots & \ddots & \vdots \\
  -1 &  0 &  0 &  0 & \cdots & 1 & a_n \\
\end{pmatrix}
Celdor
  • 9,058
鈴木悠真
  • 141
  • 3

2 Answers2

7

Here is a solution with {pNiceArray} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

[\begin{pNiceArray}{cccccc:c} 1&-1&0&0&\cdots&0&a_1\ 0&1&-1&0&\cdots&0&a_2\ 0&0&1&-1&\cdots&0&a_3\ \vdots&\vdots&\vdots&\vdots&\ddots&\vdots\ -1&0&0&0&\cdots&1&a_n \end{pNiceArray}]

\end{document}

You need several compilations because of the PGF/Tikz nodes used under the hood by nicematrix.

Output of the above code

F. Pantigny
  • 40,250
5

Use last column as a 1 row matrix besides the row where you want \vdots centred

enter image description here

\documentclass{article}
\usepackage{array,arydshln}
\begin{document}
\[
  \left(
    \begin{array}{@{} *6{c};{1pt/2pt}c @{}}
      1  & -1 & 0  & 0  & \cdots & 0 & a_1   \\
      0  & 1  & -1 & 0  & \cdots & 0 & a_2   \\
      0  & 0  & 1  & -1 & \cdots & 0 & a_3   \\
      \vdots & \vdots & \vdots & \vdots & \ddots & \vdots \\
      -1 & 0  & 0  & 0  & \cdots & 1 & a_{n} \\
    \end{array}
  \right)
\]
\end{document}
Celdor
  • 9,058