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

| improve this answer | |
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

| improve this answer | |
  • 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 '19 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 '19 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}
| improve this answer | |
2

EDIT after the advice of the 2019-10-24 of the author of nicematrix @F. Pantigny reported in the comment.

As another alternative you could add with appropriate modifications using the nicematrix package. For example using the environment {pNiceMatrix} with the option last-col=5.

You can see that you will have the same result as output.

enter image description here

\documentclass[12pt]{article}
\usepackage{nicematrix}
\begin{document}
\[\mathbf{H}= \begin{pNiceMatrix}[last-col=5]
1 & 2 & 3 & 5 & 10\\
 1 & 1 & 4 & 2 & 10\\
4 & 1 & 2 & 4 & 10\\
\end{pNiceMatrix}
\]
\end{document}
| improve this answer | |
  • 1
    you can delete row with \phantom and than replace pNiceArrayRC with pNiceArrayC and you will obtain the same result :-) – Zarko May 2 '19 at 21:39
  • @Zarko Of course. :-) – Sebastiano May 2 '19 at 21:42
  • @Zarko Don you know the reason of my downvote? – Sebastiano May 3 '19 at 17:22
  • No, I don't know. Your answer not deserve this. Unfortunately I cant up-vote again :-(. – Zarko May 3 '19 at 19:29
  • 1
    @Sebastino: You should update your answer because {pNiceArrayC} is now deprecated in the package nicematrix. You may use {pNiceArray} with the option last-col instead or even {pNiceMatrix} with the option last-col=5. – F. Pantigny Oct 24 '19 at 19:14

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.