¿Cómo alinear verticalmente el texto antes de blockarray en el paquete blkarray?

¿Cómo alinear verticalmente el texto antes de blockarray en el paquete blkarray?

Tengo que etiquetar el índice de filas y columnas alrededor de la matriz. Sé blkarrayque ayudaría, así que escribo así:

\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}

Aquí está el resultado: ingrese la descripción de la imagen aquí Quiero saber por qué no está alineado verticalmente en forma de blkarray.

Y cómo alinearlo verticalmente como pmatrix.

Gracias.

Respuesta1

El problema es que la matriz de bloques está centrada verticalmente con respecto a todo su tamaño, incluidos los índices siguientes.

La forma más sencilla, en este caso, es poner todo en el archivo 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}

ingrese la descripción de la imagen aquí

Respuesta2

Puede obtener este resultado con pmatrixy pstricks, definiendo ciertos elementos como nodos y adjuntando etiquetas a estos nodos, o con blockarray, stackengineo makecelly un \raiseboxcomando:

\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} 

ingrese la descripción de la imagen aquí

Respuesta3

Con {pNiceMatrix}of nicematrix, tendrás directamente el 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}

Salida del código anterior

información relacionada