3

In huge calculations it's often very helpful as reader to have nice remarks about which manipulation was made. Also, other remarks in equations can help alot, e.g., this one

enter image description here

which I like more than the ^-convention. I am generating the above with the following code

\vertarrowbox{e_j}{$i$\textsuperscript{th} spot}

where

\newcommand\vertarrowbox[3][2ex]{%
    \begin{array}[t]{@{}c@{}} #2 \\[-0.7ex]
        \left\uparrow\vcenter{\hrule height #1}\right.\kern-\nulldelimiterspace\\[-1.2ex]
        \makebox[0pt]{\scriptsize#3}
    \end{array}%
}

My goal now is to achieve something similar. I am looking for something like this

enter image description here

to denote that the exchange of the two variables gives a minus sign.

I wonder how I could implement this. I am not sure if tikz-cd is the way to go (I don't have experience with tikz-cd in equations like this and don't know if it is even possible to use it this way).

Thank you for your ideas!

Mathy
  • 151
  • I would use plain tikz and the tikzmark library, see for example https://tex.stackexchange.com/a/209056/3929 – daleif Mar 03 '21 at 15:50
  • @daleif Thank you very much! Please see my own answer. Maybe you can help me further. – Mathy Mar 03 '21 at 16:53

1 Answers1

2

After @daleif gave me the tip to use tikz and tikzmark I found how to do it with some trial and error (tikz seems super complex and powerful). Please correct or improve this solution (I am not fully aware of every comment and if this could be done more nicely of if I am doing something very stupid here).

\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{equation} f(\tikzmarknode{a}a,b,c,d,\tikzmarknode{e}e) = -f(e,b,c,d,a) \end{equation}

\begin{tikzpicture}[overlay,remember picture] \draw [>=latex,<->] (a.south) to[out=-90,in=-90,looseness=1] node [below,sloped] (TextNode1) {\scriptsize$\cdot (-1)$} (e.south); \end{tikzpicture}

yields

enter image description here

However two problems remain:

  1. I want to apply this in an align environment. But then the spacing is messed up:

     \begin{align*}
          f(a,b,c,d,e) &= f(\tikzmarknode{a}a,b,c,d,\tikzmarknode{e}e) \\
                       &= -f(e,b,c,d,a)
     \end{align*}
    

enter image description here

  1. As I will use this very often in the document, I want to write a command for it. But how could I implement that? The obvious problem is that the \begin{tikzpicture}[overlay,remember picture] thing has to come after the whole align environment and I have only ever worked with commands which "replace in place".

Any help is very much appreciated!

EDIT: I added a brace underneath to better symbolize what term exactly is moved. Also read my comment under this answer. enter image description here

Mathy
  • 151
  • I decided that it was a huge overkill to write a command for this. My knowledge in LaTeX is way too bad for that. Imagine I wanted to use the command twice in one align environment. Many problems come up. Instead, I will just use my first approach as above in every single case and maybe give more vertical space after the \ in the align enviroment by hand. – Mathy Mar 04 '21 at 09:06
  • may be you should increase the vertical spacing in the align block to fix the text overlap . \begin{align*} f(a,b,c,d,e) &= f(\tikzmarknode{a}a,b,c,d,\tikzmarknode{e}e) \\[2cm] &= -f(e,b,c,d,a) \end{align*} – Hafid Boukhoulda Mar 04 '21 at 13:27
  • @HafidBoukhoulda Yes, that's what I am doing now. It's not nice that way, but it works. Thanks! – Mathy Mar 04 '21 at 15:28