Math & ScienceHow to add matrix in a formula

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
lynnlee
Posts: 50
Joined: Fri Jan 04, 2013 10:15 am

How to add matrix in a formula

Post by lynnlee »

Dear all,

I tried to add the matrix in a math formula, but the matrix was distorted in shape. The code I use is the following:

Code: Select all

\documentclass[a4paper,11pt]{article}
\begin{document}
$y=\sum_{i} x_{i} \begin{bmatrix} 1 & 1 &1 \\ 1& 1 & 1\\1 & 1& 1 \end{bmatrix}$
\end{document}
Any suggestions about how to let the matrix align in a good shape and be added to the math formula?
Thank you.

Lynn

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to add matrix in a formula

Post by Johannes_B »

Hi, the code as is does not compile because amsmath is missing. Adding package mathtools (as it patches amsmath at some occasions) gives me the following.
lynnleeMatrix.png
lynnleeMatrix.png (851 Bytes) Viewed 2916 times
I can't see any distortion. Can you clarify what you mean?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
lynnlee
Posts: 50
Joined: Fri Jan 04, 2013 10:15 am

Re: How to add matrix in a formula

Post by lynnlee »

Thank you so much. With \usepackage{mathtools}, the code works perfectly fine.

Lynn
Post Reply