Math & ScienceMatrix cell space and arrows as markers

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
salehin
Posts: 34
Joined: Wed Jun 10, 2009 1:29 am

Matrix cell space and arrows as markers

Post by salehin »

When I use those arrows along with their marker to denote i'm unable to produce a nice looking matrix [arrow in correct spaces and each cell of equal size]. I've added a complied pdf file as well. Thanks for reading.

Regards,

Ash

Code: Select all

\documentclass[a4paper,12pt, final]{article}
\usepackage{amsmath}
\usepackage[margin=2.54cm,top=2.54cm]{geometry}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}


\begin{document}

\begin{align*}
& \quad \text{ }\underset{\downarrow }{1}\quad \underset{\downarrow }{k}%
\qquad \underset{\downarrow }{x}\ \underset{\downarrow }{i} \\
H=& \left[
\begin{array}{cccc}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 \\
1 & 0 & 0 & 0 \\
0 & \left( 1-\rho \right)  & 0 & 1 \\
0 & 0 & \rho  & 0%
\end{array}
\right]
\begin{array}{c}
\leftarrow 1 \\
\leftarrow k \\
\leftarrow x \\
\leftarrow i \\
\leftarrow 1 \\
\leftarrow k^{\prime } \\
\leftarrow x^{\prime }%
\end{array}
\end{align*}

\end{document}
Attachments
test.pdf
(42.83 KiB) Downloaded 462 times

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

Matrix cell space and arrows as markers

Post by gmedina »

Hi,

some adjustments can improve your matrix:

Code: Select all

\documentclass[a4paper,12pt, final]{article}
\usepackage{amsmath}
\usepackage[margin=2.54cm,top=2.54cm]{geometry}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{array}

\begin{document}

\[
\begin{array}{c}
  \hspace*{-3pt}%
  \begin{array}{cccc}
    \hphantom{0} & \hphantom{\left( 1-\rho \right)} & \hphantom{0} & \hphantom{0}\\[-15pt]
    1 & k & x & i\\
    \downarrow & \downarrow & \downarrow & \downarrow
  \end{array} \\
  H= \left[%
  \begin{array}{cccc}
    1 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 \\
    0 & 0 & 1 & 0 \\
    0 & 0 & 0 & 1 \\
    1 & 0 & 0 & 0 \\
    0 & \left( 1-\rho \right)  & 0 & 1 \\
    0 & 0 & \rho  & 0%
  \end{array}
  \right]
  \begin{array}{@{\leftarrow\, }c}
    1 \\
    k \\
    x \\
    i \\
    1 \\
    k^{\prime } \\
    x^{\prime }%
  \end{array}
\end{array}
\]

\end{document}
The bigdelim package could be useful too.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
salehin
Posts: 34
Joined: Wed Jun 10, 2009 1:29 am

Re: Matrix cell space and arrows as markers

Post by salehin »

Thanks gmedina. :)

If possible, can you please advise how to make column width of equal size [, cf. the 3rd and 4th column in this case].

Regards,

Ash

ps: just noticed about the package you've mentioned! I'll have a look at it.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Matrix cell space and arrows as markers

Post by gmedina »

Hi Ash,
salehin wrote:Thanks gmedina. :)

If possible, can you please advise how to make column width of equal size [, cf. the 3rd and 4th column in this case]...
You are welcome! The first, third and fourth columns of my example code already have the same width... so I don't understand your question.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
salehin
Posts: 34
Joined: Wed Jun 10, 2009 1:29 am

Re: Matrix cell space and arrows as markers

Post by salehin »

Hi gmedina

I meant each column of equal width - i think LaTeX does the autosizing of colum/row-width, based on how many stuffs in cells of a col/row - thus making them unequal.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Matrix cell space and arrows as markers

Post by gmedina »

You can use p{<length>} to explicitly declare a column width. The following code produces a matrix with four columns, each having a width of 1.3cm. For an explanation on some of the commands and constructs used in the format declaration of the array environments, please refer to the documentation of the array package:

Code: Select all

\documentclass[a4paper,12pt, final]{article}
\usepackage[margin=2.54cm,top=2.54cm]{geometry}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{array}

\begin{document}

\[
\begin{array}{c}
  \hspace*{-3pt}%
  \begin{array}{*{4}{>{\centering\arraybackslash$}p{1.3cm}<{$}}}
    1 & k & x & i\\
    \downarrow & \downarrow & \downarrow & \downarrow
  \end{array} \\
  H= \left[%
  \begin{array}{*{4}{>{\centering\arraybackslash$}p{1.3cm}<{$}}}
    1 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 \\
    0 & 0 & 1 & 0 \\
    0 & 0 & 0 & 1 \\
    1 & 0 & 0 & 0 \\
    0 & \left( 1-\rho \right)  & 0 & 1 \\
    0 & 0 & \rho  & 0%
  \end{array}
  \right]
  \begin{array}{@{\leftarrow\, }c}
    1 \\
    k \\
    x \\
    i \\
    1 \\
    k^{\prime } \\
    x^{\prime }%
  \end{array}
\end{array}
\]

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
salehin
Posts: 34
Joined: Wed Jun 10, 2009 1:29 am

Re: Matrix cell space and arrows as markers

Post by salehin »

Thank you again for your kind help, gmedina. It is much appreciated. :)
Post Reply