Math & ScienceColumn Separation in Matrices and Spacing around Equal Sign

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Column Separation in Matrices and Spacing around Equal Sign

Post by Cham »

I'm still having problems with spacing in matrices. Until now, I was able to fix them using several tricks and "hacks", but now I don't know what to do with this case here (compilable example):

Code: Select all

\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\begin{document}

Bla bla bla
	\begin{align*}
		A =
		\left[ \begin{array}{c|ccc}
			\gamma & 0 & 0 & -\, \gamma \, v \\
			\hline 0 & 1 & 0 & 0 \\
			0 & 0 & 1 & 0 \\
			-\, \gamma \, v & 0 & 0 & \gamma \\
		\end{array} \right]\!\!
		&\left[ \begin{array}{c|ccc}
			0 & 0 & 0 & g \\
			\hline 0 & 0 & 0 & 0 \\
			0 & 0 & 0 & 0 \\
			g & 0 & 0 & 0 \\
		\end{array} \right]\!\!
		\left[ \begin{array}{c|ccc}
			\gamma & 0 & 0 & \gamma \, v \\
			\hline 0 & 1 & 0 & 0 \\
			0 & 0 & 1 & 0 \\
			\gamma \, v & 0 & 0 & \gamma \\
		\end{array} \right]\!.
	\end{align*}
Bla bla bla

\end{document}
Here's a preview of the output :
matrices.jpg
matrices.jpg (26.15 KiB) Viewed 3191 times
The problems are these :
  1. The spacing after the equal sign is a bit too much. I don't know what is wrong in my code above.
  2. The columns spacing is horrible in the first and third matrices, especially in the first matrix because of the - sign. I need them to be equally spaced.
What would you suggest to have nicely looking matrices in this case ?

Recommended reading 2024:

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

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

Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Column Separation in Matrices and Spacing around Equal Sign

Post by Cham »

While I successfully "hacked" my matrices, nobody have a suggestion about how to do it "right" ?

I added lots of small spaces, using \, \; \! and phantom{ }, to get this (the columns are very approximately equally spaced) :
matrices2.jpg
matrices2.jpg (36.48 KiB) Viewed 3167 times
Using my approach, I think that matrices in LaTeX are really cumbersome to create. I always have to "hack" them in an unatural manner.
Post Reply