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