Como posso ter uma chave à esquerda e no topo de uma matriz sem sobreposição?

Como posso ter uma chave à esquerda e no topo de uma matriz sem sobreposição?

Considere o seguinte código:

\documentclass{article}

\usepackage{amsmath}
\usepackage{rotating}

\begin{document}

\begin{align*}
  \rotatebox[origin=c]{90}{$n$ parts}\left\{\overbrace{\begin{matrix}
    \bullet & \bullet & \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \cdots & \bullet\\
    \bullet & \cdots & \bullet\\
  \end{matrix}}^{\text{Even number}}\right.
\end{align*}

\begin{align*}
  \rotatebox[origin=c]{90}{$n$ parts}\overbrace{\left\{\begin{matrix}
    \bullet & \bullet & \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \cdots & \bullet\\
    \bullet & \cdots & \bullet\\
  \end{matrix}\right.}^{\text{Even number}}
\end{align*}

\end{document}

Isso produz a seguinte saída:

insira a descrição da imagem aqui

Em ambos os casos, uma das chaves se sobrepõe à outra. Gostaria de poder fazer com que cada chave começasse e terminasse exatamente em um dos pontos do diagrama. Como posso fazer isso?

Responder1

Aqui está uma maneira de fazer isso:

\documentclass{article}

\usepackage{amsmath}
\usepackage{rotating}

\begin{document}

\begin{equation*}
  %
  % the vertical brace
  %
  \rotatebox[origin=c]{90}{\scriptsize{
    $n$ parts
  }}
  %
  % an invisible matrix for height
  %
  \left\{\begin{matrix}
     \vphantom{} \\ \vphantom{} \\ \vphantom{} \\
     \vphantom{} \\ \vphantom{} \\ \vphantom{} \\
  \end{matrix}\right.
  %
  % the horizontal brace and the visible matrix
  %
  \overbrace{
    \begin{matrix}
      \bullet & \bullet & \bullet & \bullet & \bullet & \cdots & \bullet\\
      \bullet & \bullet & \bullet & \cdots & \bullet\\
      \bullet & \bullet & \bullet & \cdots & \bullet\\
      \bullet & \bullet & \bullet & \cdots & \bullet\\
      \bullet & \cdots & \bullet\\
      \bullet & \cdots & \bullet\\
    \end{matrix}
  }^{\text{
    even number
  }}
\end{equation*}

\end{document}

que parece

insira a descrição da imagem aqui

Isso é muito semelhante aos seus exemplos, com apenas uma diferença: as duas chaves agora envolvem matrizes diferentes.

A matriz cujas entradas são todas \vphantom{}não aparece no documento impresso, mas tem a mesma altura da matriz de pontos. Se você aumentar ou diminuir a matriz de pontos, precisará adicionar ou remover entradas dessa matriz para compensar. Esta matriz fornece o tamanho do suporte vertical.

Em seguida, a chave horizontal envolve a matriz de pontos original e nunca vê o espaço ocupado pela chave vertical.


Alternativamente, aqui está uma solução bastante simples baseada em TikZ que usa a matrixbiblioteca para organizar as entradas e, em seguida, a decorationsbiblioteca para desenhar os colchetes.

\documentclass{article}

\usepackage{amsmath}
\usepackage{rotating}
\usepackage{tikz}

\usetikzlibrary{matrix, decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}[decoration={brace, amplitude=6pt}]
    \matrix (m) [matrix of math nodes] {
      \bullet & \bullet & \bullet & \bullet & \bullet & \cdots & \bullet\\
      \bullet & \bullet & \bullet & \cdots & \bullet\\
      \bullet & \bullet & \bullet & \cdots & \bullet\\
      \bullet & \bullet & \bullet & \cdots & \bullet\\
      \bullet & \cdots & \bullet\\
      \bullet & \cdots & \bullet\\
    };
    \draw [decorate, transform canvas={xshift=-0.3em}, thick]
           (m-6-1.south west) -- node [left=6pt]
           {\rotatebox[origin=c]{90}{\scriptsize\text{$n$ parts}}} (m-1-1.north west);
    \draw [decorate, transform canvas={yshift=0.5em, xshift=0.5em}, thick]
          (m-1-1.north west) -- node [above=6pt]
          {\scriptsize\text{even number}} (m-1-6.north east);
\end{tikzpicture}

\end{document}

Esta é a aparência da solução TikZ:

insira a descrição da imagem aqui

Responder2

Veja como você pode fazer isso com pilhas:

\documentclass{article}
\usepackage{tabstackengine}
\stackMath
\begin{document}
\setbox0=\hbox{\setstacktabbedgap{1ex}\tabbedCenterstack{
    \bullet & \bullet & \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \bullet & \bullet & \cdots & \bullet\\
    \bullet & \cdots & \bullet\\
    \bullet & \cdots & \bullet
}}
\[
\Shortstack[r]{%
  {\stackon{\makebox[\wd0]{\downbracefill}}{\textrm{top~text}}}\\
  {\textrm{side~text}\left\{\box0\right.}
}
\]
\end{document}

insira a descrição da imagem aqui

Responder3

Aqui está o que você pode fazer com {NiceMatrix}( nicematrix≥ 6,4 de 23/11/2021):

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

$\begin{NiceMatrix}
  \Block{*-1}{\rotate n \text{ parts}}
  & \bullet & \bullet & \bullet & \bullet & \bullet & \cdots & \bullet\\
  & \bullet & \bullet & \bullet & \cdots & \bullet\\
  & \bullet & \bullet & \bullet & \cdots & \bullet\\
  & \bullet & \bullet & \bullet & \cdots & \bullet\\
  & \bullet & \cdots & \bullet\\
  & \bullet & \cdots & \bullet\\
\CodeAfter
  \OverBrace{1-2}{1-last}{\text{even number}}[yshift=1mm]
  \SubMatrix{\{}{1-2}{last-2}{.}[left-xshift=0.8mm]
\end{NiceMatrix}$

\end{document}

Você precisa de várias compilações (porque nicematrixusa nós PGF/Tikz nos bastidores).

Saída do código acima

informação relacionada