5

I would like to produce the following matrix : enter image description here:

My code is below which only produces the matrix without the additional column.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{equation*}
    \mathbf{H}=
    \begin{pmatrix}
        1 & 2 & 3 & 5\\
        1 & 1 & 4 & 2\\
        4 & 1 & 2 & 4
    \end{pmatrix}
   \end{equation*}
\end{document}
7

One possibility might be to employ blkarray.

\documentclass{article}
\usepackage{blkarray}
\usepackage{amsmath}
\begin{document}  
\[\begin{blockarray}{(>{\:}cccc<{\:})l}
       1 & 2 & 3 & 5 & 10\\
        1 & 1 & 4 & 2 & 10\\
        4 & 1 & 2 & 4 & 10 \\
\end{blockarray}\]
\end{document}

enter image description here

5

One possible option is just adding another matrix.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{equation*}
    \mathbf{H}=
    \begin{pmatrix}
        1 & 2 & 3 & 5\\
        1 & 1 & 4 & 2\\
        4 & 1 & 2 & 4
    \end{pmatrix}
    \begin{matrix}
        10\\10\\10
    \end{matrix}
   \end{equation*}
\end{document}

enter image description here

  • Your solution works in this special case where all matrix cells have the standard height. It doesn't work when the cells contain something like \frac{\frac12}3. – Roland Illig Apr 27 at 13:34
  • Sure, LaTeX has many packages for dealing with cases with different complexities, but one should go for the simplest solution first, generalization has its cost! – AboAmmar Apr 27 at 14:17
5

Considering that matrices are also arrays, I provide a version with basic LaTeX tools:

enter image description here

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[\mathbf{H}=\Bigg(
\begin{array}{cccc}
    1 & 2 & 3 & 5\\
    1 & 1 & 4 & 2\\
    4 & 1 & 2 & 4
\end{array}\Bigg)
\begin{array}{c}
    10\\
    10\\
    10
\end{array}
\]

\end{document}
2

As another alternative you could add with appropriate modifications using the nicematrix package. For example the environment {pNiceArrayC} (thank you very much for the suggestion of @Zarko (see comment)) add a matrix with an exterior column.

You can get the same result as the starting image and the other answers.

enter image description here

\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\[\mathbf{H}=\begin{pNiceArrayC}{CCCC}
1 & 2 & 3 & 5 & 10\\
 1 & 1 & 4 & 2 & 10\\
4 & 1 & 2 & 4 & 10\\
\end{pNiceArrayC}
\]
\end{document}
  • 1
    you can delete row with \phantom and than replace pNiceArrayRC with pNiceArrayC and you will obtain the same result :-) – Zarko May 2 at 21:39
  • @Zarko Of course. :-) – Sebastiano May 2 at 21:42
  • @Zarko Don you know the reason of my downvote? – Sebastiano May 3 at 17:22
  • No, I don't know. Your answer not deserve this. Unfortunately I cant up-vote again :-(. – Zarko May 3 at 19:29
  • @Zarko I am not very expert of LaTeX but I have understood, many times, because I receveid severals downvotes without an explanation. I am very interesting to increase my experience in LaTeX and I'm not interesting for votes. Thank you very much always. Bye. – Sebastiano May 3 at 19:32

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.