答案1
你可以用 来做这件事nicematrix
。最难的部分是让箭头出现在每个片段上。
\documentclass{article}
\usepackage{nicematrix, tikz}
\usetikzlibrary{decorations.pathreplacing, arrows.meta, decorations.markings}
\tikzset{arrow every segment/.style={
decoration={
show path construction,
lineto code={\path[decorate, decoration={markings, mark=at position .6 with {\arrow{Latex}}}] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
}
}, postaction={decorate}
}}
\begin{document}
\[
\begin{bNiceMatrix}[cell-space-limits=1.25ex]
1 & \gamma\tanh(\beta) & \cdot & \cdot\\
\cdot & 1 & \cdot & \gamma\tanh(\beta)\\
\gamma\tanh(\beta) & \cdot & 1 & \cdot\\
\cdot & \cdot & \gamma\tanh(\beta) & 1
\CodeAfter
\tikz
\draw[semithick, cyan, arrow every segment, line join=round, line cap=round] (1.5-|1.5)--(3.5-|1.5)--(3.5-|3.5)
--(4.5-|3.5)--(4.5-|4.5)--(2.5-|4.5)--(2.5-|2.5)
--(1.5-|2.5)--(1.5-|1.5);
\end{bNiceMatrix}
\]
\end{document}