评论

评论

如何在不改变列条目的水平对齐方式的情况下绘制以下类型的矩阵:

|   c11 c12 c13   c14   c15 c16   c17 | c18 c19 | |
|   c21 c22 c23   c24 | c25 c26 | c27   c28 c29   |
|   c31 c32 c33   c34 | c35 c36 | c37   c38 c39   |
| | c41 c42 c43 | c44   c45 c46   c47   c48 c49   |

备注:主矩阵内有三个子矩阵:

子矩阵 1:c18 至 c19
子矩阵 2:c25 至 c36
子矩阵 3:c41 至 c43

其中|显示为大尺寸括号()

这个问题不同于 矩阵中的矩阵

答案1

评论

我希望我理解了你的解释。

使用特定的\tikzmarkcalligraphyAndrew Stacey 的 TikZ 库,您可以实现以下输出。您需要重新运行latex几次才能获得正确的定位。

执行

\documentclass{standalone}
\usepackage{amsmath,tikz}
\usetikzlibrary{decorations,calligraphy}
\newcommand\tikzmark[2]{\tikz[remember picture,baseline=(#1.base)]{\node[inner sep=0pt] (#1) {#2};}}
\begin{document}
$
\begin{pmatrix}
    c11  & c12 & c13  & c14 & c15                   & c16                   & c17 & (c18 & c19) \\
    c12  & c22 & c23  & c24 & \tikzmark{c25}{$c25$} & \tikzmark{c26}{$c26$} & c27 & c28  & c29  \\
    c13  & c32 & c33  & c34 & \tikzmark{c35}{$c35$} & \tikzmark{c36}{$c36$} & c37 & c38  & c39  \\
    (c14 & c42 & c43) & c44 & c45                   & c46                   & c47 & c48  & c49  \\
\end{pmatrix}
$
\begin{tikzpicture}[remember picture,overlay]
    \draw[thick,decorate,decoration={calligraphic straight parenthesis}] (c35.south west) -- (c25.north west);
    \draw[thick,decorate,decoration={calligraphic straight parenthesis}] (c26.north east) -- (c36.south east);
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述


使用calc库,您可以通过添加偏移量来补偿 TikZ 括号的不良间距,.2em

\begin{tikzpicture}[remember picture,overlay]
    \draw[thick,decorate,decoration={calligraphic straight parenthesis}] ($(c35.south west)+(-.2em,0)$) -- ($(c25.north west)+(-.2em,0)$);
    \draw[thick,decorate,decoration={calligraphic straight parenthesis}] ($(c26.north east)+(.2em,0)$) -- ($(c36.south east)+(.2em,0)$);
\end{tikzpicture}

产生

在此处输入图片描述


代表 Christopher Creutzig 的评论,这里还有另一个解决方案(仍然使用tikzmark),它不涉及在矩阵内输入括号。

\documentclass{standalone}
\usepackage{amsmath,tikz}
\usetikzlibrary{calc,decorations,calligraphy}
\newcommand\tikzmark[2]{\tikz[remember picture,baseline=(#1.base)]{\node[inner sep=0pt] (#1) {#2};}}
\begin{document}
$
\begin{pmatrix}
    c11                   & c12 & c13                   & c14 & c15                   & c16                   & c17 & \tikzmark{c18}{$c18$} & \tikzmark{c19}{$c19$} \\
    c12                   & c22 & c23                   & c24 & \tikzmark{c25}{$c25$} & \tikzmark{c26}{$c26$} & c27 & c28                   & c29                   \\
    c13                   & c32 & c33                   & c34 & \tikzmark{c35}{$c35$} & \tikzmark{c36}{$c36$} & c37 & c38                   & c39                   \\
    \tikzmark{c14}{$c14$} & c42 & \tikzmark{c43}{$c43$} & c44 & c45                   & c46                   & c47 & c48                   & c49                   \\
\end{pmatrix}
$
\begin{tikzpicture}[remember picture,overlay]
    \draw[thick,decorate,decoration={calligraphic straight parenthesis}] ($(c35.south west)+(-.2em,0)$) -- ($(c25.north west)+(-.2em,0)$);
    \draw[thick,decorate,decoration={calligraphic straight parenthesis}] ($(c26.north east)+(.2em,0)$) -- ($(c36.south east)+(.2em,0)$);
    \node[left=.2em] at (c14) {$($};
    \node[left=.2em] at (c18) {$($};
    \node[right=.2em] at (c19) {$)$};
    \node[right=.2em] at (c43) {$)$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

以下 MWE 以适当的大小插入括号 (..):

在此处输入图片描述

\documentclass{article}
\begin{document}
\[
  \left(\begin{array}{@{\hspace*{1ex}}*{9}{c}@{\hspace*{1ex}}}
    c_{11} & c_{12} & c_{13} & c_{14} & c_{15} & c_{16} & c_{17} & \llap{$\bigl($}c_{18} & c_{19}\rlap{$\bigr)$} \\
    c_{21} & c_{22} & c_{23} & c_{24} & \llap{\raisebox{\dimexpr\ht\strutbox-\height}[0pt][0pt]{$\biggl($}}c_{25} & 
      c_{26}\rlap{\raisebox{\dimexpr\ht\strutbox-\height}[0pt][0pt]{$\biggr)$}} & c_{27} & c_{28} & c_{29} \\
    c_{31} & c_{32} & c_{33} & c_{34} & c_{35} & c_{36} & c_{37} & c_{38} & c_{39} \\
    \llap{$\bigl($}c_{41} & c_{42} & c_{43}\rlap{$\bigr)$} & c_{44} & c_{45} & c_{46} & c_{47} & c_{48} & c_{49}
  \end{array}\right)
\]
\end{document}

重叠允许保持水平间距,而括号则使用其\big* 等效项调整大小。

答案3

使用{pNiceMatrix}ofnicematrix及其内置命令\SubMatrix

\documentclass{article}
\usepackage{nicematrix}

\begin{document}
$\begin{pNiceMatrix}[margin]
c11 & c12 & c13 & c14 & c15 & c16 & c17 & c18 & c19 \\
c12 & c22 & c23 & c24 & c25 & c26 & c27 & c28 & c29 \\
c13 & c32 & c33 & c34 & c35 & c36 & c37 & c38 & c39 \\
c14 & c42 & c44 & c45 & c46 & c47 & c48 & c48 & c49 
\CodeAfter
  \SubMatrix({1-7}{1-8})
  \SubMatrix({2-5}{3-6})
  \SubMatrix({4-1}{4-3})
\end{pNiceMatrix}$
\end{document}

上述代码的输出

相关内容