LaTeX Creating Matrices in LaTeX for Linear Algebra: Tips and Troubleshooting

  • Thread starter Thread starter lo2
  • Start date Start date
  • Tags Tags
    Latex Matrices
AI Thread Summary
The discussion focuses on formatting matrices in LaTeX for a linear algebra document. The original user encountered errors while trying to create a custom matrix command. A solution is provided, demonstrating the correct usage of the amsmath package, which offers various matrix environments such as pmatrix, bmatrix, Bmatrix, vmatrix, and Vmatrix. An example is given, showing how to properly format a 4x4 matrix using these environments, ensuring the matrices appear as intended in the final document. The importance of including the amsmath package in the document preamble is emphasized for successful matrix formatting.
lo2
Hi there I am writing about linear algebra and therefore I need to type matrices. I thought I could do this.

\newcommand{\metar}[16]{\left [ \begin{array}{cccc} #1 & #2 & #3 & #4 \\ #5 & #6 & #7 & #8 \\ #9 & #10 & #11 & #12 \\ #13 & #14 & #15 & #16 \end{array} \right ] }

But I get errors and it does not look as desired...

So please help!
 
Physics news on Phys.org
Is this all you were trying to do?

<br /> \left[ \begin{array}{cccc} 1 &amp; 2 &amp; 3 &amp; 4 \\ 5 &amp; 6 &amp; 7 &amp; 8 \\ 9 &amp; 10 &amp; 11 &amp; 12 \\ 13 &amp; 14 &amp; 15 &amp; 16 \end{array} \right]<br />

just click on the above and you can see the TeX. You basically had everything there.
 
Last edited:
The amsmath package also gives you 5 matrix environments:
Code:
\documentclass[article]{memoir}
\usepackage{amsmath}
\begin{document}
\[
\begin{pmatrix}
  1 & 2 & 3 & 4\\
  5 & 6 & 7 & 8\\
  9 &10 &11 &12\\
  13&14 &15 &16
\end{pmatrix}
\begin{bmatrix}
  1 & 2 & 3 & 4\\
  5 & 6 & 7 & 8\\
  9 &10 &11 &12\\
  13&14 &15 &16
\end{bmatrix}
\begin{Bmatrix}
  1 & 2 & 3 & 4\\
  5 & 6 & 7 & 8\\
  9 &10 &11 &12\\
  13&14 &15 &16
\end{Bmatrix}
\begin{vmatrix}
  1 & 2 & 3 & 4\\
  5 & 6 & 7 & 8\\
  9 &10 &11 &12\\
  13&14 &15 &16
\end{vmatrix}
\begin{Vmatrix}
  1 & 2 & 3 & 4\\
  5 & 6 & 7 & 8\\
  9 &10 &11 &12\\
  13&14 &15 &16
\end{Vmatrix}
\]
\end{document}
 

Similar threads

Replies
15
Views
25K
Replies
3
Views
2K
Replies
4
Views
3K
Replies
1
Views
2K
Replies
1
Views
4K
Replies
4
Views
4K
Replies
7
Views
8K
Replies
1
Views
3K
Back
Top