GeneralMatrix

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Snoop1990
Posts: 5
Joined: Fri Mar 28, 2008 2:46 pm

Matrix

Post by Snoop1990 »

In general the argument in an Matrix are centered. Is there a way to have them left orientated ?

Simple example:
$$\begin{matrix} x\\ abc \end{matrix}$$

now the above x is over the b but I like to have the x over the a and but there should not be a gap between abc so they should be in one cell.
Snoop1990.uni.cc (personal blog)

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Matrix

Post by localghost »

As a replacement you can use the array environment. But then you have to give a column type to control the alignment of the single columns.

Code: Select all

\[
  \begin{array}{l} x \\ abc \end{array}
\]
The reason why you should not use $$...$$ for displayed mathematical expressions can be found in l2tabu. You can tweak the behaviour of the array environment with the array package.


Best regards
Thorsten¹
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Matrix

Post by Stefan Kottwitz »

Hi Snoop1990,

regarding matrices and mathematics in general I recommend to use the amsmath package, see for instance the amsmath user's guide 4.1 Matrices. It provides matrices with different delimiters like (), [], {} and || and with more economical horizontal spacing.

Though the column entries will be centered too here's a small modification for the internal macro \env@matrix. By copying this code to your preamble you will be able to use \matrix, \pmatrix, \bmatrix, \Bmatrix, \vmatrix and \Vmatrix with an optional parameter l,r or c (default) for the alignment:

Code: Select all

\usepackage{amsmath}
...
\makeatletter
\renewcommand*\env@matrix[1][c]{\hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{*\c@MaxMatrixCols #1}}
\makeatother
For more information with examples you may have a look at Matrices with alignment.

Stefan
LaTeX.org admin
balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Matrix

Post by balf »

The mathtools package has a series of matrix*, pmatrix*, ..., environments that admit an optional argument : l, r or c (the default).

B.A.
Snoop1990
Posts: 5
Joined: Fri Mar 28, 2008 2:46 pm

Re: Matrix

Post by Snoop1990 »

Thank you very much for your help !
Snoop1990.uni.cc (personal blog)
Post Reply