7

Can you help me how to do that dashed line on this matrix ?

Can you help me how to do that dashed line on this matrix

4

I will add another simple solution if you like.

enter image description here

\documentclass{article}
\usepackage{arydshln}
\usepackage{mathtools}
\begin{document}
\[ \left[
\begin{array}{c:c}
1 &  2 \\ 
3 & 4 \\
5 & 6 \\ 
\end{array} \right] \]
\end{document}

ADDENDUM: 2020-7-24. Using {bNiceArray} of nicematrix package you will have the square brackets at the same position as in {bmatrix} of amsmath.

\documentclass[a4paper,12pt]{article}

\usepackage{nicematrix}
\usepackage{arydshln}

\NiceMatrixOptions{letter-for-dotted-lines=V}

\begin{document}
$\begin{bNiceArray}{c:c}
1 & 2 \\
3 & 4 \\
5 & 6
\end{bNiceArray}$
\end{document}

Remark: If you don't put \NiceMatrixOptions{letter-for-dotted-lines=V}, you will have a dotted line (drawn by nicematrix).

Result of the second code

| improve this answer | |
  • The dashes are of different lengths which is more or less inevitable if you have long dashes. Is it possible to make them shorter and more tightly packed? – Anush Jul 24 at 8:22
  • Instead of \left[\begin{NiceArray}...\end{NiceArray}\right], it's possible to use \begin{bNiceArray}...\end{bNiceArray} with the same result (which is a result similar to {bmatrix} of amsmath). – F. Pantigny Jul 24 at 8:48
  • @F.Pantigny Very kind F. Pantigny you are right totally. The reason of my addendum is the same: I'm using papeeria.com that can compile with your previous version of nicematrix (I use the most recent TeXlive2019). Please, can you edit my addenudum adding your screenshot? Thank you very much. – Sebastiano Jul 24 at 11:55
  • 1
    @Sebastiano: I have edited your addendum :-) – F. Pantigny Jul 24 at 12:38
  • @F.Pantigny Excellent. Always thank you. – Sebastiano Jul 24 at 12:42
9

Try

\documentclass{article}
\usepackage{amsmath}
\usepackage{arydshln}
\begin{document}
\begin{equation}
\left[
    \begin{array}{c;{2pt/2pt}c}
        -2 & -4 \\
         2 & -1 \\
        -8 & 16
    \end{array}
\right]
\end{equation}
\end{document}

To obtain

enter image description here

| improve this answer | |
  • Unfortunately, it does not work for me; it (TeXStudio) says: Package array Error: Illegal pream-token (;): c' used. \begin{array}{c;{2pt/2pt}c} Package array Error: Illegal pream-token (2pt/2pt):c' used. \begin{array}{c;{2pt/2pt}c} – Alex Konnen Dec 13 '19 at 19:04
  • 1
    @AlexKonnen works fine here. add a MWE and I'll try to see what happens. – Denis Dec 18 '19 at 7:34
  • I have found the reason why it did not work: my document included \usepackage{tabularx}; I assume that \usepackage{arydshln} is somehow incompatible with the latter; if I remove tabularx, the code works, with tabularx it does not. – Alex Konnen Dec 19 '19 at 19:38
  • The vertical dashes seem to end with a short bold dash. Can this be avoided? – Anush Jul 24 at 8:24
  • You can try to modify the option of the dashed line. Here I set 2pt / 2pt. – Denis Jul 24 at 10:06

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.