Wie kann ich Text vor einem Blockarray im Blkarray-Paket vertikal ausrichten?

Wie kann ich Text vor einem Blockarray im Blkarray-Paket vertikal ausrichten?

Ich muss Zeilen- und Spaltenindex um die Matrix herum beschriften. Ich weiß blkarray, dass das helfen würde, also schreibe ich so:

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

Hier ist das Ergebnis: Bildbeschreibung hier eingeben Ich möchte wissen, warum die vertikale Ausrichtung nicht im Blu-Ray-Modus erfolgt.

Und wie man es vertikal ausrichtet, wie bei pmatrix.

Danke.

Antwort1

Das Problem besteht darin, dass das Block-Array in Bezug auf seine gesamte Größe, einschließlich der darunter liegenden Indizes, vertikal zentriert ist.

Der einfachste Weg ist in diesem Fall, das Ganze in das zu legen 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}

Bildbeschreibung hier eingeben

Antwort2

Sie können dieses Ergebnis entweder mit pmatrixund erzielen pstricks, indem Sie bestimmte Elemente als Knoten definieren und diesen Knoten Beschriftungen hinzufügen, oder mit blockarray, stackengineoder makecellund einem \raiseboxBefehl:

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

Bildbeschreibung hier eingeben

Antwort3

Mit {pNiceMatrix}von nicematrixerhalten Sie direkt das erwartete Ergebnis.

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

Ausgabe des obigen Codes

verwandte Informationen