Math & ScienceHelp with matrices

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
notnek
Posts: 11
Joined: Mon Dec 07, 2009 5:09 pm

Help with matrices

Post by notnek »

Hello,

I have three questions:

1) How would I draw a 6x6 matrix with dots as entries and a line that indicates the main diagonal?

2) In my current latex document, large matrices appear stretched vertically. Is there a way to make them more square (I'm using {amssymb}, [fleqn]{amsmath}, {tikz} and pmatrix to draw matrices)

3) http://tiny.cc/2smxs How do I draw the G symbol located just after the highlated text?

Thanks in advance,

Michael

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

Help with matrices

Post by gmedina »

Hi,

for 3):

Code: Select all

\documentclass{article}
\usepackage{amssymb}

\begin{document}

$\mathcal{G}$

\end{document}
for 1) and 2) please post a minimal working example allowing us to see how exactly are you building your matrices.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
notnek
Posts: 11
Joined: Mon Dec 07, 2009 5:09 pm

Help with matrices

Post by notnek »

Thank you!

Code: Select all

\documentclass[12pt,a4paper]{article}

\usepackage{amssymb}
\usepackage[fleqn]{amsmath}
\usepackage{tikz}

\linespread{1.5}

\numberwithin{equation}{subsection}

\tolerance = 10000
\setlength{\oddsidemargin}{8mm}
\setlength{\evensidemargin}{8mm}
\setlength{\topmargin}{-5mm}


\setlength{\textwidth}{145mm}
\setlength{\textheight}{220mm}
\begin{document}

$\begin{pmatrix}.&.&.&.&.&.\\.&.&.&.&.&.\\.&.&.&.&.&.\\.&.&.&.&.&.\\.&.&.&.&.&.\\.&.&.&.&.&.\end{pmatrix}$

\end{document}
For 1) I'd like a matrix like this (less vertically stretched) with a line that goes through the leading diagonal.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Help with matrices

Post by gmedina »

For your matrix with a diagonal line, you could use something like this:

Code: Select all

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}\small
\matrix (magic) [matrix of math nodes, left delimiter = (, right delimiter = )]
  {%
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  };
  \draw[thin,help lines] (magic-1-1.north west) -- (magic-6-6.south east);
\end{tikzpicture}

\end{document}
For the vertical stretching issue you can use the optional argument of \\:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[ 
  \begin{pmatrix}
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot \\[-1.5ex]
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot \\[-1.5ex]
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot \\[-1.5ex]
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot \\[-1.5ex]
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot \\[-1.5ex]
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot
\end{pmatrix}
\]

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
notnek
Posts: 11
Joined: Mon Dec 07, 2009 5:09 pm

Help with matrices

Post by notnek »

gmedina wrote:For your matrix with a diagonal line, you could use something like this:

Code: Select all

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}\small
\matrix (magic) [matrix of math nodes, left delimiter = (, right delimiter = )]
  {%
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  \cdot & \cdot & \cdot & \cdot & \cdot & \cdot \\
  };
  \draw[thin,help lines] (magic-1-1.north west) -- (magic-6-6.south east);
\end{tikzpicture}

\end{document}
For the vertical stretching issue you can use the optional argument of \\:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[ 
  \begin{pmatrix}
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot \\[-1.5ex]
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot \\[-1.5ex]
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot \\[-1.5ex]
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot \\[-1.5ex]
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot \\[-1.5ex]
    \cdot &\cdot &\cdot &\cdot &\cdot & \cdot
\end{pmatrix}
\]

\end{document}
Thank you!
Post Reply