如何在矩陣上方放置扭結箭頭?

如何在矩陣上方放置扭結箭頭?

我想實現這樣的目標:

在此輸入影像描述

或可選地帶有尖銳的扭結:

在此輸入影像描述

那可能嗎?

我偶然發現這個帖子以及一些使用 tikz 但無法根據我的需求進行調整的答案。

答案1

歡迎來到 TeX.se,請考慮給予 MWE。這將有助於我們準確地回答您的問題,也節省了我們去水晶球的時間;-)

一個起點

\documentclass{article}
\usepackage{tikz}
\newcommand{\tikzmark}[1]{\tikz[overlay, remember picture] \coordinate (#1);}
%https://tex.stackexchange.com/questions/40535/matrix-with-arrows-and-labels
\begin{document}
\[
  X = \qquad \bordermatrix{~  &  ~ & ~ & ~ & ~
                        & ~  \cr
                    \tikzmark{varrowtop} ~ & 0 & 0 & 0 & 1 & 1\tikzmark{harrowright} \cr
                    ~ & 0 & 0 & 1 & 1 & 1 \cr
                    ~ & 0 & 0 & 1 & 1 & 0 \cr
                    ~ & 0 & 0 & 1 & 1 & 0 \cr
                    \tikzmark{varrowbottom}~ & 0 & 0 & 0 & 0 & 0 \cr
                    }
\]
\tikz[overlay,remember picture] {
  \draw[->] (varrowbottom) -- ([yshift=3ex]varrowtop)  -- ([yshift=3ex]harrowright)
            node[midway,above] {};
}
\end{document}

要得到:

在此輸入影像描述

光滑的邊角:

\documentclass{article}
\usepackage{tikz}
\newcommand{\tikzmark}[1]{\tikz[overlay, remember picture] \coordinate (#1);}
\begin{document}
\[
  X = \qquad \bordermatrix{~  &  ~ & ~ & ~ & ~
                        & ~  \cr
                    \tikzmark{varrowtop} ~ & 0 & 0 & 0 & 1 & 1\tikzmark{harrowright} \cr
                    ~ & 0 & 0 & 1 & 1 & 1 \cr
                    ~ & 0 & 0 & 1 & 1 & 0 \cr
                    ~ & 0 & 0 & 1 & 1 & 0 \cr
                    \tikzmark{varrowbottom}~ & 0 & 0 & 0 & 0 & 0 \cr
                    }
\]
\tikz[overlay,remember picture] {
  \draw[->, rounded corners] (varrowbottom) -- ([yshift=3ex]varrowtop)  -- ([yshift=3ex]harrowright)
            node[midway,above] {};
}
\end{document}

要得到:

在此輸入影像描述

答案2

這是一個使用{pNiceMatrix}ofnicematrix和 TikZ 的解決方案,透過使用 建立的 TikZ 節點來繪製箭頭nicematrix

\documentclass{article}
\usepackage{nicematrix,tikz}

\begin{document}

\[X = 
\quad 
\begin{pNiceMatrix}
0 & 0 & 0 & 1 & 1 \\
0 & 0 & 1 & 1 & 1 \\
0 & 0 & 1 & 1 & 0 \\
0 & 0 & 1 & 1 & 0 \\
0 & 0 & 0 & 0 & 0 \\
\CodeAfter
  \tikz [-> , rounded corners = 2mm ]
     \draw ([xshift=-2mm]last-|1) |- ([yshift=2mm]1-|last) ; 
\end{pNiceMatrix}
\]

\end{document}

上述程式碼的輸出

相關內容