5

I would like to enhance the output given by the following code : see the picture below where the end of the arrow is lower and the loop "bigger".

To do this I need a better control of the Bezier curve and also I would like to add a minus sign inside the loop.

\documentclass{article}

\usepackage{tikz}
\usepackage{nicematrix}

\begin{document}

$\begin{vNiceMatrix}[first-row]
    u & v  \\
    x & x'  \\
    y & y'
    \CodeAfter
    \tikz \draw [red,->]
        (1-1.east) .. 
            controls (2-2.south east) 
            and
            (2-1.south west)
        .. (1-2.west) ;
\end{vNiceMatrix}$

\end{document}

enter image description here

projetmbc
  • 13,315

1 Answers1

5

I would use the in and out keys (and make the matrix a bit bigger so that the annotations do not clash with the matrix entries).

\documentclass{article}

\usepackage{tikz}
\usepackage{nicematrix}

\begin{document}

$\begin{vNiceMatrix}[first-row,columns-width=1.5em]
    u & v  \\
    x & x'  \\
    y & y'
    \CodeAfter
    \begin{tikzpicture}
     \path (1-1.east) -- node[below=0.35em,red,inner sep=0pt] (minus) {$-$} (1-2.west);
     \draw [red,->]
        (1-1.east) to[out=0,in=30]  (minus.south east) 
        to[out=-150,in=-30]  (minus.south west)
        to[out=150,in=180] (1-2.west);
    \end{tikzpicture}           
\end{vNiceMatrix}$

\end{document}

enter image description here

Or maybe also make sure that the arrow attaches at the same vertical position.

\documentclass{article}

\usepackage{tikz}
\usepackage{nicematrix}

\begin{document}

$\begin{vNiceMatrix}[first-row,columns-width=1.5em]
    u & v  \\
    x & x'  \\
    y & y'
    \CodeAfter
    \begin{tikzpicture}
     \path (1-1.east) -- node[below=0.35em,red,inner sep=0pt] (minus) {$-$} (1-2.west);
     \draw [red,->]
        (1-1.east) to[out=0,in=30]  (minus.south east) 
        to[out=-150,in=-30]  (minus.south west)
        to[out=150,in=180] (1-1.east-|1-2.west);
    \end{tikzpicture}           
\end{vNiceMatrix}$

\end{document}

enter image description here

Or even more symmetric.

\documentclass{article}

\usepackage{tikz}
\usepackage{nicematrix}
\usetikzlibrary{calc}
\begin{document}

$\begin{vNiceMatrix}[first-row,columns-width=1.5em]
    u & v  \\
    x & x'  \\
    y & y'
    \CodeAfter
    \begin{tikzpicture}
     \path (1-1.east) -- node[below=0.35em,red,circle,inner sep=1pt] (minus) {$-$} (1-2.west);
     \draw [red,->] let \p1=($(minus.east)-(minus.center)$) in 
        (1-1.east) to[out=0,in=150]  (minus.60) 
        arc[start angle=60,end angle=-240,radius=\x1] 
        to[out=30,in=180] (1-1.east-|1-2.west);
    \end{tikzpicture}           
\end{vNiceMatrix}$
\end{document}

enter image description here

  • Thanks a lot. Why does (1-1.east-|1-2.west) do the trick for the vertical position ? – projetmbc Jun 09 '20 at 20:41
  • 2
    @projetmbc The syntax (1-1.east-|1-2.west) means "take the y component of 1-1.east and the x component of 1-2.west). It is very nicely described in https://tex.stackexchange.com/a/401429 –  Jun 09 '20 at 20:45
  • Thanks for this clarification and the link. – projetmbc Jun 09 '20 at 21:55
  • I use ($(1-1.east) + (0.05,0)$). How can I acheive a similar thing but to the arrow ? – projetmbc Jun 12 '20 at 19:35
  • 2
    @projetmbc Sorry, I do not understand this comment. How are you using ($(1-1.east) + (0.05,0)$) (which can be translated to ([yshift=0.5mm]1-1.east))? (Or are you looking for ...([yshift=-0.5mm]1-1.east) coordinate (aux) ... (aux-|1-2.west)?) –  Jun 12 '20 at 19:41
  • That does the trick. Thanks ! I want that the start and the end of the arrow to be less near to the text. – projetmbc Jun 12 '20 at 20:16
  • 1
    @projetmbc You can use the keys shorten >=1pt,shorten <=1pt, say. –  Jun 12 '20 at 20:19
  • Ok. I note this way to do the right thing. – projetmbc Jun 12 '20 at 20:30