I want to create the following picture in LaTeX. How can I do this?
[Tex/LaTex] How to create this matrix in LaTeX
math-modematrices
Related Solutions
If you need the vertical and horizontal lines around the matrix blocks, the following solution (which also doesn't require TikZ) may be of interest. (I've updated the example to reflect the update in your question, which appears to require an extra \ddots
row/column.)
Note that I use the array
environment rather than the matrix
(or pmatrix
) environment as it's necessary to right-align the contents of some columns.
\documentclass{article}
\usepackage{amsmath,array}
\renewcommand\arraycolsep{4pt} % default value: 6pt
% short-hand commands for multicolumn entries with vertical bar
% on left and right hand sides, respectively
\newcommand{\mcl}[1]{\multicolumn{1}{|r}{#1}}
\newcommand{\mcr}[1]{\multicolumn{1}{r|}{#1}}
\begin{document}
\begin{equation*}
\left( \,\begin{array}{rcr rcr rr c rr}
\cline{1-3}
\mcl{1} & & \mcr{} \\
\mcl{} & \ddots & \mcr{} \\
\mcl{} & & \mcr{1} \\
\cline{1-6}
& & & \mcl{-1} & & \mcr{} \\
& & & \mcl{} & \ddots & \mcr{} \\
& & & \mcl{} & & \mcr{-1}\\
\cline{4-8}
& & & & & & \mcl{\cos \omega} & \mcr{-\sin \omega}\\
& & & & & & \mcl{\sin \omega} & \mcr{ \cos \omega}\\
\cline{7-8}
& & & & & & & & \ddots\\
\cline{10-11}
& & & & & & & & & \mcl{\cos \omega} & \mcr{-\sin \omega}\\
& & & & & & & & & \mcl{\sin \omega} & \mcr{ \cos \omega}\\
\cline{10-11}
\end{array}\,\right)
\end{equation*}
\end{document}
Addendum: Using the \boxed
macro, the code that sets up this matrix can be simplified considerably:
\documentclass{article}
\usepackage{amsmath,array}
\renewcommand\arraycolsep{4pt} % default value: 6pt
\begin{document}
\begin{equation*}
\left( \,
\begin{array}{r@{}r@{}r r r} % @{} is used twice to suppress intercolumn whitespace
\boxed{ \begin{array}{rrr} % First block
1 \\
& \ddots\\
& & 1 \\
\end{array} } \\
& \boxed{ \begin{array}{rrr} % Second block
-1 \\
& \ddots\\
& & -1\\
\end{array} } \\
& & \boxed{ \begin{array}{rr} % Third block
\cos \omega & -\sin \omega\\
\sin \omega & \cos \omega\\
\end{array} } \\
& & & \ddots\\ % Fourth "block" -- not boxed
& & & & \boxed{ \begin{array}{rr} % Fifth block
\cos \omega & -\sin \omega\\
\sin \omega & \cos \omega\\
\end{array} } \\
\end{array}\,\right)
\end{equation*}
\end{document}
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[ %\arraycolsep=4pt
G =
\begin{bmatrix*}[r]
1 \\
2&1\\
-1&2&1\\
&-1&2&1\\
&&-1&2&1\\
&&&-1&2&1\\
&&&&&&\ddots\\
&&&&&&&\ddots\\
&&&&&&&&\ddots\\
&&&&&&&&&1
\end{bmatrix*}
\]
\end{document}
Best Answer
Hope this will serve as a starting point for the OP to learn. Here the proposal uses array where you specifies how many columns you need, for example, by using
cccc
for 4 columns centered, and then separate each column by & and ends the line by \.Code
Edit: Recommended by barbara beeton, a flush right solution.
Code: