Math & ScienceInline aligned matrices

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
gjm
Posts: 2
Joined: Tue Sep 14, 2010 6:27 pm

Inline aligned matrices

Post by gjm »

Hi,

In http://www.latex-community.org/forum/vi ... 68&start=0, it is explained how to produce inline right-aligned vectors using the smallmatrix environment.

Could anyone give me the solution to inline right-aligned matrices?

Thank you very much,

GJM.
Last edited by gjm on Wed Sep 15, 2010 4:19 pm, edited 1 time in total.

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Inline aligned matrices

Post by gmedina »

Hi,

there was an extra \hfil command in the rsmallmatrix environment that I posted in the thread you linked to; here's the corrected version:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\makeatletter
% smallmatrix with right alignment
\newenvironment{rsmallmatrix}{\null\,\vcenter\bgroup
  \Let@\restore@math@cr\default@tag
  \baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
  \ialign\bgroup\hfil$\m@th\scriptstyle##$&&\thickspace\hfil
  $\m@th\scriptstyle##$\crcr
}{%
  \crcr\egroup\egroup\,%
}
\makeatother

\begin{document}

$\left(\begin{rsmallmatrix}
  12 & -456 & -23 \\
  1  & 6  & 1 \\
  -12345 & 78 & 5 \\
\end{rsmallmatrix}\right)$

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Inline aligned matrices

Post by localghost »

A slightly different approach to that from the gmedina in the mentioned topic.

Code: Select all

\documentclass[12pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{graphicx}
\usepackage{mathtools}        % Loads »amsmath«

\begin{document}
    The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. \raisebox{0.5ex}{\scalebox{0.4}{\( \smash{\begin{pmatrix*}[r] -a_{11} & a_{12} & -a_{13} \\  a_{11} & -a_{12} & a_{13} \\ a_{11} & -a_{12} & -a_{13} \end{pmatrix*}} \)}} The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
\end{document}

Best regards and welcome to the board
Thorsten
gjm
Posts: 2
Joined: Tue Sep 14, 2010 6:27 pm

Re: Inline aligned matrices

Post by gjm »

Perfect (I prefer the first approach :) ) and thank you again.
GJM.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Inline aligned matrices

Post by localghost »

Now that the problem is obviously solved, please be so kind and mark the topic accordingly as you have already been directed in my last reply.
Post Reply