30 在latex中,矩阵中怎么画这实线框和虚线框

发布于 2024-11-08 22:56:54
关注者
0
被浏览
140
Sagittarius Rover
我要成为TikZ糕手/(ㄒoㄒ)/~~

一个可能的答案是:

\documentclass{article}
\usepackage{amsmath,amssymb,mathrsfs}
\usepackage{nicematrix}
\usepackage{tikz}
\newcommand*{\BB}[1][]{\mathscr{B}^{#1}}
\begin{document}
    \[ 
        \begin{NiceMatrix}[create-medium-nodes]
            \phantom{0} & \alpha_1 & \alpha_2 & \cdots & \alpha_t & \phantom{0}  \\
            \phantom{0} & \BB \alpha_1 & \BB \alpha_2 & \cdots & \BB \alpha_t & \phantom{0} \\
            \phantom{0} & \BB[2] \alpha_1 & \BB[2] \alpha_2 & \cdots & \BB[2] \alpha_t &\phantom{0}  \\
            \phantom{0} & \vdots & \vdots & \ddots & \vdots &\phantom{0}  \\
            \phantom{0} & \BB[k_1-1] \alpha_1 & \BB[k_2-1] \alpha_2 & \cdots & \BB[k_n-1] \alpha_t &\phantom{0}  \\
            \phantom{0} & \BB[k_1] \alpha_1 & \BB[k_2] \alpha_2 & \cdots & \BB[k_n] \alpha_t & \phantom{0} \\
        \CodeAfter
            \tikz[name suffix=-medium]{
                \draw[cyan,dashed] (1-2.north west) rectangle (5-5.south east);
                \draw[magenta!60] (2-1.north west) rectangle (6-6.south east);
            }
        \end{NiceMatrix}
    \]
\end{document}

image.png

-------------------------补充回答-------------------------

\documentclass{article}
\usepackage{amsmath,amssymb,mathrsfs}
\usepackage{nicematrix}
\usepackage{tikz}
\newcommand*{\BB}[1][]{\mathscr{B}^{#1}}
\begin{document}
    \[ 
        \begin{NiceMatrix}[create-medium-nodes]
            \phantom{1} & \alpha_1 & \alpha_2 & \cdots & \alpha_t & \phantom{1}  \\
            \phantom{1} & \BB \alpha_1 & \BB \alpha_2 & \cdots & \BB \alpha_t & \phantom{1} \\
            \phantom{1} & \BB[2] \alpha_1 & \BB[2] \alpha_2 & \cdots & \BB[2] \alpha_t &\phantom{1}  \\
            \phantom{1} & \vdots & \vdots & \ddots & \vdots &\phantom{1}  \\
            \phantom{1} & \BB[k_1-1] \alpha_1 & \BB[k_2-1] \alpha_2 & \cdots & \BB[k_n-1] \alpha_t &\phantom{1}  \\
            \phantom{1} & \BB[k_1] \alpha_1 & \BB[k_2] \alpha_2 & \cdots & \BB[k_n] \alpha_t & \phantom{1} & \alpha_{t+1} & \cdots & \alpha_s \\
        \CodeAfter
            \tikz[name suffix=-medium]{
                \draw[cyan,dashed] (1-2.north west) rectangle (5-5.south east);
                \draw[magenta!60] (2-1.north west) rectangle (6-6.south east);
            }
        \end{NiceMatrix}
    \]
\end{document}

image.png

1 个回答

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览