4

I would like to achieve something like this:

enter image description here

or optionally with a sharp kink:

enter image description here

Is that possible?

I stumbled across this post and some answers where tikz was used but wasn't able to adjust it to my need.

2 Answers2

6

Welcome to TeX.se, please consider giving an MWE. This will help us a lot to answer your question accurately, also saves us time from going to our crystal balls ;-).

A starting point

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

to get:

enter image description here

Smooth corners:

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

to get:

enter image description here

  • 2
    Nice, but notice that there is a tikzmark package (which has the advantage of working even if the marks are defined after their usage...) – Rmano Feb 19 '19 at 12:02
  • 1
    @Rmano Thanks for the remark. Till now, I did not knew its existence. I will take a note of it and go through it when I have some time. And, ensure it gets reflected in my future answers :-). – Raaja_is_at_topanswers.xyz Feb 19 '19 at 12:54
3

Here is a solution with {pNiceMatrix} of nicematrix and TikZ to draw the arrow by using the TikZ nodes created by 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}

Output of the above code

F. Pantigny
  • 40,250