Math & Science ⇒ Matrix in LaTeX
Matrix in LaTeX
How do I get a matrix nicer than the one with the commands below?
\begin{center}
$Q_3$=\begin{pmatrix}-3&3&0&0\\1&-3&2&0\\0&2&-3&1\\0&0&0&0\end{pmatrix}
\end{center}
This will give me the correct matrix but the "-"signs make it look ugly for bigger matrices....
Does anyone know how to get the "-"signs a bit to the left so that the actual numbers form smooth columns?
Thanks alot!
Kind regards,
A.
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Matrix in LaTeX
Code: Select all
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools} % loads »amsmath«
\begin{document}
\[
Q_3=
\begin{pmatrix*}[r]
-3 & 3 & 0 & 0 \\
1 & -3 & 2 & 0 \\
0 & 2 & -3 & 1 \\
0 & 0 & 0 & 0
\end{pmatrix*}
\]
\end{document}Best regards
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10