1

I've used simple-wick and simpler-wick but in neither of them I can put arrows in the lines conecting the elements of the contractions.

Does anybody know how to do that?

I can do something with tikz and Xelatex, but I cannot figure it out how to make it work with math symbols.

\documentclass{article}
\usepackage{tikz,bm}
\newcommand\C[1]{\tikz[remember picture]{\node(#1)[inner sep=0pt] 
{\sffamily#1};}}
\usepackage{tikz}
\usepackage{refcount}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc}
\begin{document}

\tikzset{->-/.style={decoration={
 markings,
 mark=at position .5 with {\arrow{>}}},postaction={decorate}}}

\tikzset{-<-/.style={decoration={
 markings,
 mark=at position .5 with {\arrow{<}}},postaction={decorate}}}




\begin{equation}
\begin{tabular}{@{}*7{c@{}}}
\C{a}&\C{B}&\C{C}& $\bm\sim$ &\C{X}&\C{Y}&\C{Z}  
\end{tabular}
\mathord{
\begin{tikzpicture}[overlay,remember picture,>=latex,shorten >=1pt,shorten 
<=1pt,very thin]
\draw[->-] (a) --++(0,10pt) -| (X);
\draw[-<-] (B) --++(0,14pt) -| (Y);
\draw[-<-] (C) --++(0,-14pt) -| (Z);
\end{tikzpicture}
 }
\end{equation}

\end{document}

Which gives me something like enter image description here

  • @marmot thank you for your observations! I don't know what I'm writing wrong, but when I write \C{\phi} o $\C{\phi}$ it keeps appearing the message ! Missing $ inserted.$ \C{\phi}. How should I write it? – Siddhartha Morales Sep 21 '18 at 17:55
  • You may just look at my answer to this question and rename \tikznode to \C. This should work. Personally I would use the new tikzmark library though. –  Sep 21 '18 at 18:09
  • @marmot Sorry, but it didn't. I'm very happy with your implementation of simpler-wick package anyways. Thanks – Siddhartha Morales Sep 21 '18 at 18:19

1 Answers1

1

Welcome to TeX.SE! A very simpleminded proposal is to just slightly change one definition of the simpler-wick package.

\documentclass{article}
\usepackage{simpler-wick}
\newif\ifWickArrow
\WickArrowfalse
\pgfkeys{
  /simplerwick/.cd,
  arrow/.code={\WickArrowtrue},
  no arrow/.code={\WickArrowfalse}
}

\makeatletter
\def\swick@end#1#2{
  \swick@setfalse@#1
  \tikzexternaldisable
  \begin{tikzpicture}[remember picture, baseline=(swick-close#1.base)]
    \node[use as bounding box, inner sep=0pt, outer sep=0pt] (swick-close#1) {$\displaystyle #2$};
  \end{tikzpicture}
  \tikz[remember picture, overlay]
{\ifWickArrow  
    \draw[-latex] ($(swick-open#1.north) + (0, 3pt)$) 
          -- ($(swick-open#1.base) + (0, \swick@offset) + #1*(0, \swick@sep)$) 
          -- ($(swick-close#1.base) + (0, \swick@offset) + #1*(0, \swick@sep)$) 
          -- ($(swick-close#1.north) + (0, 1pt)$);
\else         
    \draw ($(swick-open#1.north) + (0, 3pt)$) 
          -- ($(swick-open#1.base) + (0, \swick@offset) + #1*(0, \swick@sep)$) 
          -- ($(swick-close#1.base) + (0, \swick@offset) + #1*(0, \swick@sep)$) 
          -- ($(swick-close#1.north) + (0, 3pt)$);
\fi}
  \tikzexternalenable}
\makeatother
\begin{document}
\begin{equation}
  \wick[arrow]{\c\phi A \c\phi}
\end{equation}
\begin{equation}
  \wick{\c\phi A \c\phi}
\end{equation}
\end{document}

enter image description here

As you see, \wick now accepts an option arrow that makes it draw an arrow. This is a minimal surgery, which does not allow you to combine contractions with and without arrows in the same equation. It might be possible to extend this surgery to allow this also, but that won't be minimal any more. Therefore, I'd like to ask you whether or not such mixed cases are needed.

ADDENDUM: A quick modification that allows you to draw the contractions below, and to put the arrow in the middle. This version comes with a list of arrows that is to be passed to \wick. The first entry defines the arrows for all contractions of type \c1, the second is for \c2 and so on.

\documentclass{article}
\usepackage{simpler-wick}
\usetikzlibrary{decorations.markings}
% from https://tex.stackexchange.com/a/39282/121799
\tikzset{W->-/.style={decoration={
  markings,
  mark=at position 0.5*\pgfdecoratedpathlength+2pt with
  {\draw[-latex] (-2pt,0pt) -- (1pt,0pt);}},postaction={decorate}},
  W-<-/.style={decoration={
  markings,
  mark=at position 0.5*\pgfdecoratedpathlength with
  {\draw[latex-] (-2pt,0pt) -- (1pt,0pt);}},postaction={decorate}}
  }
\newif\ifWickBelow
\WickBelowfalse
\pgfkeys{
  /simplerwick/.cd,
  arrows/.store in=\LstWickArrows,
  arrows={-,-,-,-,-,-,-,-,-},
  arrows/.initial={-,-,-,-,-,-,-,-,-}, % the # of contractions is bounded by 9
  below/.code={\WickBelowtrue},
}

\makeatletter
\def\swick@end#1#2{
  \swick@setfalse@#1
  \tikzexternaldisable
  \begin{tikzpicture}[remember picture, baseline=(swick-close#1.base)]
    \node[use as bounding box, inner sep=0pt, outer sep=0pt] (swick-close#1) {$\displaystyle #2$};
  \end{tikzpicture}
  \tikz[remember picture, overlay]
{
\foreach \W@X[count=\W@C] in \LstWickArrows
{\ifnum\W@C=#1
\xdef\myW@style{\W@X}
\fi}
\ifWickBelow
    \draw[\myW@style] ($(swick-open#1.south) + (0, -3pt)$) 
          -- ($(swick-open#1.base) + (0, -\swick@offset) + #1*(0, -\swick@sep)$) 
          -- ($(swick-close#1.base) + (0, -\swick@offset) + #1*(0, -\swick@sep)$) 
          -- ($(swick-close#1.south) + (0, -3pt)$);
\else
    \draw[\myW@style] ($(swick-open#1.north) + (0, 3pt)$) 
          -- ($(swick-open#1.base) + (0, \swick@offset) + #1*(0, \swick@sep)$) 
          -- ($(swick-close#1.base) + (0, \swick@offset) + #1*(0, \swick@sep)$) 
          -- ($(swick-close#1.north) + (0, 3pt)$);
\fi}
  \tikzexternalenable}
\makeatother
\begin{document}
\begin{enumerate}
\item You can specify single arrows like \texttt{W->-} or \texttt{W-<-}: $\displaystyle
  \wick[arrows={-,W->-,W-<-}]{
    \c1 a \c2 b \c3 c \c1 a d \c1 e
    \c1 e \c1 a \c2 b \c3 c \c1 a
  }
$
\item The default is not to draw arrows: $\displaystyle
  \wick{
    \c1 a \c2 b \c3 c \c1 a d \c1 e
    \c1 e \c1 a \c2 b \c3 c \c1 a
  }
$
\item \texttt{below} allows you to draw the contraction below the
equation: $\displaystyle
  \wick[arrows={-,W->-,W-<-},below]{
    \c1 a \c2 b \c3 c \c1 a d \c1 e
    \c1 e \c1 a \c2 b \c3 c \c1 a
  }$
\item Another example: $\displaystyle
  \wick[arrows={W->-,W-<-,-},below]{
    \c1 a \c2 b \c3 c \c1 a d \c1 e
    \c1 e \c1 a \c2 b \c3 c \c1 a
  }$
\item The ordinary keys work as well, e.g.\ to put arrows at the ends: $\displaystyle
  \wick[arrows={latex-,-latex,-},below]{
    \c1 a \c2 b \c3 c \c1 a d \c1 e
    \c1 e \c1 a \c2 b \c3 c \c1 a
  }$
\bigskip
\item Sometimes you may want to add vertical space by hand: $\displaystyle
  \wick[arrows={stealth-,-latex,-}]{
    \c1 a \c2 b \c3 c \c1 a d \c1 e
    \c1 e \c1 a \c2 b \c3 c \c1 a
  }$
\end{enumerate}
\end{document}

enter image description here

As you already see here, you may want to add vertical space. This is because the contractions are drawn as overlays. Note also that one may make the package a bit more powerful once the new version of tikzmark is on CTAN.

  • Thank you very very much!!!! I know that I'm being to demanding, but do you know how to put the arrow in the middle? And how could I change the package to have mixed contractions (i.e. some with arrows and some with no arrows), and arrows in both directions. Thanks again, you are a reincarnate god! – Siddhartha Morales Sep 21 '18 at 04:49
  • @SiddharthaMorales I made an update, which is the second part of my answer. It is rather flexible, except that the arrows can "only" be specified per level. That is, you cannot have two \c1 type contractions with different arrows. I hope that this allows you to do what you want. If not, I'd kindly ask you to ask a separate question on this, preferably after the new version of tikzmark is part of CTAN. –  Sep 21 '18 at 13:30
  • That's actually a very good idea, It's not very complicated and it's súper usefull. The last thing that could be implemented is now mixing up with down contractions. I'm working with no more than 5 contractions, but I'm wondering, how long could the list be? – Siddhartha Morales Sep 21 '18 at 13:34
  • @SiddharthaMorales If I understand the code correctly, the argument of \c cannot go beyond 9. This does of course not mean that you cannot have more than 9 contractions, but you can't have more than 9 levels. And I guess one could implement a version that allows you to have both above and below contractions in the same equation, but I'd like to encourage you to ask a separate question for this, also because this will mean that the syntax will change again, and there is not enough space in my answer to append this. –  Sep 21 '18 at 13:46