Math & ScienceSpacement problem in a column matrix

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

Spacement problem in a column matrix

Post by Cham »

I have the column-matrix shown below and its last element has a spacement problem : it has a slight horizontal offset, relative to all the other elements in the matrix (see the picture below). Of course, this is because of the size of its "N" index. How can I modify the code below, so the last element is well aligned with all the other elements above it ?

Compilable example :

Code: Select all

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{tensor}

\begin{document}
	\begin{equation}
		\begin{bmatrix}
			\tensor{\Psi}{_1} \\
			\tensor{\Psi}{_2} \\
			\tensor{\Psi}{_3} \\
			\vdots_{\phantom{3}} \\
			\tensor{\Psi}{_N}
		\end{bmatrix}
	\end{equation}
\end{document}
Here's a preview of the code above :
column.jpg
column.jpg (6.99 KiB) Viewed 2766 times

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Spacement problem in a column matrix

Post by Stefan Kottwitz »

Hi Cham,

I wrote earlier in my blog about an extension to the amsmath internal matrix environment, which can be used here. It supports additional positioning options.

If you add to your preamble:

Code: Select all

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother
then you can write in your code

Code: Select all

\begin{bmatrix}[l]
end there tensors are aligned.
matrix.png
matrix.png (3.4 KiB) Viewed 2760 times
The default centered alignment caused the bad alignment before, since one index was wider.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Spacement problem in a column matrix

Post by Cham »

Thanks for the reply.

That solution is working.

However, the vertical dots aren't aligned (centered) with the Psi.

I suspect there's another way. How can I horizonticaly "smash" the "N" index and give to it the same spacing as a "3" ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Spacement problem in a column matrix

Post by Cham »

O well, :roll:

here again, the phantoms are our friends :). The code below solves completely my problem :

Code: Select all

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{tensor}

\begin{document}
        \begin{equation}
                \begin{bmatrix}
                        \phantom{\!{}_1} \tensor{\Psi}{_1} \\
                         \phantom{\!{}_2} \tensor{\Psi}{_2} \\
                         \phantom{\!{}_3} \tensor{\Psi}{_3} \\
                         \phantom{\!{}_3} \vdots_{\phantom{3}} \\
                         \phantom{\!{}_N} \tensor{\Psi}{_N}
                \end{bmatrix}
        \end{equation}
\end{document}
Post Reply