
Eu tenho que rotular o índice de linhas e colunas em torno da matriz. Eu sei blkarray
que ajudaria, então escrevo assim:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{blkarray}% http://ctan.org/pkg/blkarray
\newcommand{\matindex}[1]{\mbox{#1}}% Matrix index
\begin{document}
pmatrix way:
\[
J(i,j,\theta)=\begin{pmatrix}
1 & \cdots & 0 & \cdots & 0 & \cdots & 0 \\
\vdots & \ddots & \vdots & & \vdots & & \vdots \\
0 & \cdots & c & \cdots & -s & \cdots & 0 \\
\vdots & & \vdots & \ddots & \vdots & & \vdots \\
0 & \cdots & s & \cdots & c & \cdots & 0 \\
\vdots & & \vdots & & \vdots & \ddots & \vdots \\
0 & \cdots & 0 & \cdots & 0 & \cdots & 1
\end{pmatrix}
\]
blkarray way:
\[
J(i,j,\theta)=\begin{blockarray}{cccccccc}
\begin{block}{(ccccccc)c}
1 & \cdots & 0 & \cdots & 0 & \cdots & 0 \\
\vdots & \ddots & \vdots & & \vdots & & \vdots \\
0 & \cdots & c & \cdots & -s & \cdots & 0 & \matindex{$i$} \\
\vdots & & \vdots & \ddots & \vdots & & \vdots \\
0 & \cdots & s & \cdots & c & \cdots & 0 & \matindex{$j$} \\
\vdots & & \vdots & & \vdots & \ddots & \vdots \\
0 & \cdots & 0 & \cdots & 0 & \cdots & 1 \\
\end{block}
& & \matindex{$i$} & & \matindex{$j$} & \\
\end{blockarray}
\]
Why $J(i,j,\theta)$ isn't vertical aligned int blkarray way?
\end{document}
Aqui está o resultado:
Quero saber por que
o alinhamento vertical não está no modo blkarray.
E como alinhá-lo verticalmente como pmatrix.
Obrigado.
Responder1
O problema é que a matriz de blocos está centralizada verticalmente em relação a todo o seu tamanho, incluindo os índices abaixo.
A maneira mais fácil, neste caso, é colocar tudo no arquivo blkarray
.
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{blkarray}% http://ctan.org/pkg/blkarray
\begin{document}
\[
\begin{blockarray}{r@{}cccccccc}
\begin{block}{r(ccccccc)c}
& 1 & \cdots & 0 & \cdots & 0 & \cdots & 0 \\
& \vdots & \ddots & \vdots & & \vdots & & \vdots \\
& 0 & \cdots & c & \cdots & -s & \cdots & 0 & i \\
J(i,j,\theta)={} & \vdots & & \vdots & \ddots & \vdots & & \vdots \\
& 0 & \cdots & s & \cdots & c & \cdots & 0 & j \\
& \vdots & & \vdots & & \vdots & \ddots & \vdots \\
& 0 & \cdots & 0 & \cdots & 0 & \cdots & 1 \\
\end{block}
& & & i & & j & \\
\end{blockarray}
\]
\end{document}
Responder2
Você pode obter esse resultado com pmatrix
e pstricks
, definindo certos elementos como nós e anexando rótulos a esses nós, ou com blockarray, stackengine
ou makecell
e um \raisebox
comando:
\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\usepackage{blkarray, makecell, stackengine}
\usepackage{pst-node, auto-pst-pdf} %
\begin{document}
\verb|pmatrix way + pstricks way:|\bigskip
\[
\begin{postscript}
J(i,j,\theta)=%
\begin{pmatrix}
1 & \cdots & 0 & \cdots & 0 & \cdots & 0 \\
\vdots & \ddots & \vdots & & \vdots & & \vdots\\
0 & \cdots & c & \cdots & -s & \cdots &\rnode{rowi}{0}\\%
\vdots & & \vdots & \ddots & \vdots & & \vdots \\
0 & \cdots & s & \cdots & c & \cdots & \rnode{rowj}{0}\\%
\vdots & & \vdots & & \vdots & \ddots & \vdots \\
0 & \cdots & \rnode{coli}{0} & \cdots & \rnode{colj}{0} & \cdots & 1
\end{pmatrix}
\psset{labelsep=1.2em}
\nput{0}{rowi}{i}\nput{0}{rowj}{j}
\psset{labelsep=1.2ex}
\nput{-90}{coli}{i}\nput{-90}{colj}{j}
\end{postscript}
\]
\verb|blkarray + makecell or stackengine way: |
\[
J(i,j,\theta)= \raisebox{-0.3\baselineskip}{$ \begin{blockarray}{(*{7}{c})c}
1 & \cdots & 0 & \cdots & 0 & \cdots & 0 \\
\vdots & \ddots & \vdots & & \vdots & & \vdots \\
0 & \cdots & c & \cdots & -s & \cdots & 0 & i\\
\vdots & & \vdots & \ddots & \vdots & & \vdots \\
0 & \cdots & s & \cdots & c & \cdots & 0 & j \\
\vdots & & \vdots & & \vdots & \ddots & \vdots \\
0 & \cdots & \smash{\stackunder[1.2ex]{0}{$ i $}} & \cdots &\smash{\makecell[tc]{0\\j}} & \cdots & 1
\end{blockarray} $}
\]%
\end{document}
Responder3
Com {pNiceMatrix}
of nicematrix
, você terá diretamente o resultado esperado.
\documentclass[a4paper,12pt]{article}
\usepackage{nicematrix}
\begin{document}
\[
J(i,j,\theta)=\begin{pNiceMatrix}[last-row=8,last-col=8]
1 & \cdots & 0 & \cdots & 0 & \cdots & 0 \\
\vdots & \ddots & \vdots & & \vdots & & \vdots \\
0 & \cdots & c & \cdots & -s & \cdots & 0 & i \\
\vdots & & \vdots & \ddots & \vdots & & \vdots \\
0 & \cdots & s & \cdots & c & \cdots & 0 & j \\
\vdots & & \vdots & & \vdots & \ddots & \vdots \\
0 & \cdots & 0 & \cdots & 0 & \cdots & 1 \\
& & i & & j & \\
\end{pNiceMatrix}
\]
\end{document}