10 如何给矩阵添加行列编号,并同时添加虚线分割?

发布于 2021-04-21 21:34:45

matrix.png

需求:

  1. 矩阵左边行标识右对齐
  2. 将矩阵用虚线分开

MWE代码

% -*- coding: utf-8 -*-
% !TEX program = xelatex

\documentclass[10pt]{beamer}

\usepackage{amsmath}
\usepackage{nicematrix}
\usepackage{braket}
\usepackage{blkarray} 


%%%=====================================%%%
\begin{document}

\begin{frame}{Matrix test}

\begin{equation*}
    \begin{blockarray}{ccccc}
        &  \ket{\phi_{B}}  &  \ket{\varphi_{\varepsilon}}  &   \ket{\phi_{B}}  &  \ket{\varphi_{\varepsilon}}   \\
        \begin{block}{r(cccc)}
            \bra{\phi_{B}}                                                          & A & A  & B  & B \\
            \displaystyle{\int \mathrm{d}\varepsilon \bra{\varphi_{\varepsilon}}}   & A & A  & B  & B \\
            %   \BAhline 
            \bra{\phi_{B}}                                                          & C & C  & D  & D \\
            \displaystyle{\int \mathrm{d}\varepsilon \bra{\varphi_{\varepsilon}}}   & C & C  & D  & D \\
        \end{block}
    \end{blockarray}
\end{equation*}

\end{frame}

\end{document}

查看更多

关注者
0
被浏览
3.1k
纸鸢 github:ZhiyuanLck
这家伙很懒,什么也没写!
\documentclass[10pt]{beamer}

\usepackage{physics}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{eqparbox}

\newcommand\eqbox[3][l]{\eqmakebox[#2][#1]{$#3$}}

\begin{document}
\begin{frame}{Matrix test}

\begin{equation*}
\begin{pNiceMatrix}[first-row, first-col]
  & \ket{\phi_{B}} & \ket{\varphi_{\varepsilon}} & \ket{\phi_{B}} & \ket{\varphi_{\varepsilon}} \\
  \eqbox{a}{\bra{\phi_{B}}} & A & A  & B  & B \\
  \eqbox{a}{\int \dd \varepsilon \bra{\varphi_{\varepsilon}}} & A & A & B & B \\
  \eqbox{a}{\bra{\phi_{B}}} & C & C  & D  & D \\
  \eqbox{a}{\int \dd \varepsilon \bra{\varphi_{\varepsilon}}} & C & C & D & D
\CodeAfter
\def\ys{1pt}
\tikz \draw[red, dashed, shorten <= 2pt, shorten >= 2pt, thick] ([yshift=\ys]3 -| 1) -- ([yshift=\ys]3 -| 5);
\tikz \draw[red, dashed, thick] (1 -| 3) -- (5 -| 3);
\end{pNiceMatrix}
\end{equation*}

\end{frame}

\end{document}

image.png

2 个回答
啸行
啸行 2021-04-21
这家伙很懒,什么也没写!
\documentclass[10pt]{beamer}
\usepackage{amsmath}
\usepackage{nicematrix}
\usepackage{braket}
\usepackage{arydshln}

\begin{document}

\begin{frame}{Matrix test}

\begin{equation*}
    \begin{pNiceArray}{cc:cc}[first-row,first-col]
        &  \bra{\phi_{B}}  &  \bra{\varphi_{\varepsilon}}  &   \bra{\phi_{B}}  &  \bra{\varphi_{\varepsilon}}   \\
        \bra{\phi_{B}} & A & A  & B  & B \\
        \displaystyle{\int \mathrm{d}\varepsilon \bra{\varphi_{\varepsilon}}} & A & A  & B  & B \\
        \cdashline{2-5}
        \bra{\phi_{B}} & C & C  & D  & D \\
        \displaystyle{\int \mathrm{d}\varepsilon \bra{\varphi_{\varepsilon}}} & C & C  & D  & D \\
    \end{pNiceArray}
\end{equation*}

\end{frame}

\end{document}

image.png

撰写答案

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

发布
问题

分享
好友

手机
浏览

扫码手机浏览