上下灯芯收缩

上下灯芯收缩

我正在使用 simpler-Wick 包,我想在同一个方程式中同时出现上下收缩。在另一个问题中,@marmot 给了我一个上下收缩的解决方案,但我想将它们混合起来。

有人能帮助我吗?

谢谢

答案1

这里有一个头脑简单这种方法可以让你混合使用位置和箭头。这在某种程度上已经超出了微创手术的范围,但我认为它仍然是可控的。

笔记:在此版本中,不再有below键。相反,您现在可以使用键来指定位置positions,键是条目列表+1(上方)或-1(下方),其长度至少应与收缩中的级别数一样长。如果不满足此要求,将出现警告,并且收缩将使用默认值绘制:上方且无箭头。

我花了一些时间编写这些修改,但没有花太多时间测试它们。如果您遇到错误或奇怪的行为,请告知我,这将非常有帮助。

以下是带有示例的代码:

\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}}
  }
\pgfkeys{
  /simplerwick/.cd,
  arrows/.store in=\LstWickArrows,
  arrows/.initial={-,-,-,-,-,-,-,-,-}, % the # of contractions is bounded by 9
  arrows={-,-,-,-,-,-,-,-,-},
  positions/.store in=\LstWickPositions,
  positions={+1,+1,+1,+1,+1,+1,+1,+1,+1},
  positions/.initial={+1,+1,+1,+1,+1,+1,+1,+1,+1},
}

\makeatletter
\newcounter{Wick@up}
\newcounter{Wick@down}
\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]
{
\xdef\myW@style{\empty}
\foreach \W@X[count=\W@C] in \LstWickArrows
{\ifnum\W@C=#1
\xdef\myW@style{\W@X}
\fi}
\ifx\myW@style\empty
\PackageWarning{simpler-wick}{%
The list arrows has not enough entries!%
}{}
\xdef\myW@style{-}
\fi
\xdef\myW@pos{-77}
\foreach \W@X[count=\W@C] in \LstWickPositions
{\ifnum\W@C=#1
\xdef\myW@pos{\W@X}
\fi}
\ifnum\myW@pos=-77
\PackageWarning{simpler-wick}{%
The list positions has not enough entries!%
}{}
\xdef\myW@pos{+1}
\fi
\ifnum\myW@pos=-1
    \draw[\myW@style] ($(swick-open#1.south) + (0, -3pt)$) 
          -- ($(swick-open#1.base) + (0, -\swick@offset) + \theWick@down*(0, -\swick@sep)$) 
          -- ($(swick-close#1.base) + (0, -\swick@offset) + \theWick@down*(0, -\swick@sep)$) 
          -- ($(swick-close#1.south) + (0, -3pt)$);
\stepcounter{Wick@down}
\else
\stepcounter{Wick@up}
    \draw[\myW@style] ($(swick-open#1.north) + (0, 3pt)$) 
          -- ($(swick-open#1.base) + (0, \swick@offset) + \theWick@up*(0, \swick@sep)$) 
          -- ($(swick-close#1.base) + (0, \swick@offset) + \theWick@up*(0, \swick@sep)$) 
          -- ($(swick-close#1.north) + (0, 3pt)$);
\fi}
  \tikzexternalenable}
\def\wick@[#1]#2{\setcounter{Wick@up}{0}
\setcounter{Wick@down}{-1}
  \ifmmode
    \begingroup
    \pgfkeys{
        simplerwick,
        #1}
    % Define the variables and commands
    \swick@cond@reset
    \swick@count=0
    \def\swick@max{0}
    \def\c{\swick@smart}
    % Here is the text
    #2
    % Add a vbox equal to max height
    \dimen0=\swick@sep
    \multiply\dimen0 by \swick@max
    \advance\dimen0 by \swick@offset
    \vbox to \dimen0{}
    % Check that every has been closed
    \swick@cond@any{
      \PackageWarning{simpler-wick}{%
        I have reached the end of \protect\wick\space with some unclosed
        contractions%
      }{}
    }{}
    \endgroup
  \else
    \PackageWarning{simpler-wick}{%
      \protect\wich\space has been called outside a math environment, this will
      be ignore%
    }
  \fi
}

\makeatother
\begin{document}
\paragraph{Note}: The lists \verb|positions| and \verb|arrows| need to have at
least as many entries as levels are involved in the contraction.
\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 You can selectatively have the contrations above or below: $\displaystyle
  \wick[positions={-1,1,-1}]{
    \c1 a \c2 b \c3 c \c1 a d \c1 e
    \c1 e \c1 a \c2 b \c3 c \c1 a
  }
$\bigskip
\item And you can combine this with arrows
equation: $\displaystyle
  \wick[arrows={-,W->-,W-<-},positions={-1,1,-1}]{
    \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-<-,-},positions={1,-1,1}]{
    \c1 a \c2 b \c3 c \c1 a d \c1 e
    \c1 e \c1 a \c2 b \c3 c \c1 a
  }$\bigskip
\item An example with a too short \verb|arrows| lists: $\displaystyle
  \wick[arrows={W->-,W-<-},positions={1,-1,1}]{
    \c1 a \c2 b \c3 c \c1 a d \c1 e
    \c1 e \c1 a \c2 b \c3 c \c1 a
  }$\bigskip  
\item An example with a too short \verb|positions| lists: $\displaystyle
  \wick[arrows={W->-,W-<-,-},positions={1,-1}]{
    \c1 a \c2 b \c3 c \c1 a d \c1 e
    \c1 e \c1 a \c2 b \c3 c \c1 a
  }$\bigskip  
\end{enumerate}
In all these examples, the appearance of \verb|\c3| implies that the lists have
to have at least 3 entries. In the last two examples, the lists are too short
and the elements have been replaced by their defaults and warnings were issued.
\end{document}

在此处输入图片描述

最后,我要说的是,如果 simpler-wick 的贡献者之一觉得我在这里做得过分了,我很乐意随时删除它。如果他们觉得他们想将其中一些合并到他们出色的软件包中,请继续,我会感到很荣幸(并且不要求任何荣誉或类似的东西)。

相关内容