Discussion:
how to typeset a matrix
kyanh
2007-03-15 01:23:15 UTC
Permalink
Hello,

I have searched through google but I could typeset the following matrix:
Loading Image...
( or: http://files.myopera.com/nducphuong/files/ma_tran_cheo.bmp )

A member of VietTUG asked me at
http://viettug.org/ao/component/option,com_simpleboard/func,view/catid,5/id,3313/#3313
but I failed to help him!

How can we typeset that matrix ?

Thank you for helps.

Regards,

kyanh
Reinhard Kotucha
2007-03-15 21:40:13 UTC
Permalink
Hello, I have searched through google but I could typeset the
http://img401.imageshack.us/img401/437/matrixxbr6.jpg
[...]
How can we typeset that matrix ?
I did not use LaTeX's picture environment for many years and I did not
use TikZ/pgf before, hence the following code is very ugly:

__________________________________________________________________
\documentclass{article}
\usepackage{tikz}
\begin{document}
\unitlength=1mm

\newcommand{\southeastarrow}{\begin{picture}(0,0)(0,0)
\put(0,-10){\tikz\draw[->] (0mm,0mm) -- (14mm,-12mm);}
\end{picture}}

\begin{displaymath}
\left(\begin{array}{ccc}
\southeastarrow a & \southeastarrow b & c \\
d & e & f \\
g & h & i \\
\end{array}\right)
\end{displaymath}

\end{document}
__________________________________________________________________


You will certainly find a better solution if you read the manuals more
carefully than I did. The TikZ/pgf manual is called pgfmanual.pgf.

http://ctan.org/tex-archive/graphics/pgf/doc/generic/pgf/version-for-pdftex/en/pgfmanual.pdf

Instead of TikZ/pgf you can also try \vector from LaTeX's picture
environment, but you should \usepackage{pict2e} which allows lines and
vectors to have arbitrary slopes.

You can also look into the XY-pic documentation, though I did not see
anything in the examples which is close to your problem and XY-pic
makes heavy use of special fonts while TikZ/pgf and pict2e can draw
straight lines with arbitrary slopes.

Even if you don't decide to use TikZ/pgf it doesn't hurt to browse the
manual. It makes as much fun as reading Hans' MataFun documentation.

Regards,
Reinhard
--
----------------------------------------------------------------------------
Reinhard Kotucha Phone: +49-511-4592165
Marschnerstr. 25
D-30167 Hannover mailto:***@web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------
Matthew Leingang
2007-03-16 01:09:56 UTC
Permalink
Post by Reinhard Kotucha
Hello, I have searched through google but I could typeset the
http://img401.imageshack.us/img401/437/matrixxbr6.jpg
[...]
How can we typeset that matrix ?
I did not use LaTeX's picture environment for many years and I did not
__________________________________________________________________
\documentclass{article}
\usepackage{tikz}
\begin{document}
\unitlength=1mm
\newcommand{\southeastarrow}{\begin{picture}(0,0)(0,0)
\put(0,-10){\tikz\draw[->] (0mm,0mm) -- (14mm,-12mm);}
\end{picture}}
\begin{displaymath}
\left(\begin{array}{ccc}
\southeastarrow a & \southeastarrow b & c \\
d & e & f \\
g & h & i \\
\end{array}\right)
\end{displaymath}
\end{document}
__________________________________________________________________
You will certainly find a better solution if you read the manuals more
carefully than I did. The TikZ/pgf manual is called pgfmanual.pgf.
Here is something quite similar. I abandoned the matrix environment
altogether and had to place nodes in what looked like the same positions and
thus had to draw my delimeters "by hand". It's not ideal (nor is it the
cleanest TikZ code) but it looks pretty good.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[baseline=1cm,xscale=0.75,yscale=0.75]
% main entries
\draw (0,2) node (a11) {$a_{11}$};
\draw (1,2) node (a12) {$a_{12}$};
\draw (2,2) node (a13) {$a_{13}$};
\draw (0,1) node (a21) {$a_{21}$};
\draw (1,1) node (a22) {$a_{22}$};
\draw (2,1) node (a23) {$a_{23}$};
\draw (0,0) node (a31) {$a_{31}$};
\draw (1,0) node (a32) {$a_{32}$};
\draw (2,0) node (a33) {$a_{33}$};
% vertical lines
\draw (-0.5,-0.5) -- (-0.5,2.5);
\draw (2.5,-0.5) -- (2.5,2.5);
% extra entries
\draw (3,2) node[gray] (a11') {$a_{11}$};
\draw (3,1) node[gray] (a21') {$a_{21}$};
\draw (3,0) node[gray] (a31') {$a_{31}$};
\draw (4,2) node[gray] (a12') {$a_{12}$};
\draw (4,1) node[gray] (a22') {$a_{22}$};
\draw (4,0) node[gray] (a32') {$a_{32}$};
% arrows
\draw[blue,->] (a11) -- (a22) -- (a33);
\draw[blue,->] (a12) -- (a23) -- (a31');
\draw[blue,->] (a13) -- (a21') -- (a32');
\draw[red,->] (a13) -- (a22) -- (a31);
\draw[red,->] (a11') -- (a23) -- (a32);
\draw[red,->] (a12') -- (a21') -- (a33);
\end{tikzpicture}
\end{document}

HTH,
Matt
--
Matthew Leingang
Preceptor in Mathematics
Harvard University

http://www.math.harvard.edu/~leingang/vCard.vcf
Jay Belanger
2007-03-16 02:54:18 UTC
Permalink
Post by kyanh
Hello,
http://img401.imageshack.us/img401/437/matrixxbr6.jpg
( or: http://files.myopera.com/nducphuong/files/ma_tran_cheo.bmp )
A member of VietTUG asked me at
http://viettug.org/ao/component/option,com_simpleboard/func,view/catid,5/id,3313/#3313
but I failed to help him!
How can we typeset that matrix ?
Here's part of a solution using pstricks:

Jay

\documentclass[12pt]{article}

\usepackage{mathtools}
\usepackage{pst-node}
\psset{linewidth=0.6pt}
\psset{nodesepA=-10pt}
\psset{nodesepB=-15pt}

\begin{document}
\[
\begin{pmatrix}
\Rnode{A}{a} & \Rnode{B}{b} & \Rnode{C}{c}\\
d & e & f \\
\Rnode{G}{g} & \Rnode{H}{h} & \Rnode{I}{i}
\end{pmatrix}
\begin{matrix}
\Rnode{AA}{a} & \Rnode{BB}{b} \\
d & e \\
\Rnode{GG}{g} & \Rnode{HH}{h}
\end{matrix}
\ncLine{->}{A}{I}
\ncLine{->}{B}{GG}
\ncline{->}{C}{HH}
\ncLine{->}{BB}{I}
\ncLine{->}{AA}{H}
\ncLine{->}{C}{G}
\]
\end{document}

Loading...