使用 {simplewick} 进行缩写

使用 {simplewick} 进行缩写

在此处输入图片描述嗨,我需要一个无穷大数下的灯芯收缩的语法。本质上是所有收缩的总和。收缩的右侧本质上没有终点。有人知道怎么做吗?照片上的最后一个方程是我需要能够写的。

答案1

simpler-wick它可能更容易被黑客入侵。

\documentclass{article}
\usepackage{simpler-wick}
\newif\ifWickCut
\WickCutfalse
\pgfkeys{
  /simplerwick/.cd,
  cut/.code={\WickCuttrue},
  no cut/.code={\WickCutfalse},
  cut ratio/.initial=0.5
}

\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]
{\ifWickCut 
    \draw ($(swick-open#1.south) + (0, -1pt)$) 
          -- ($(swick-open#1.base) + (0,3pt -1*\swick@offset) + #1*(0, -1*\swick@sep)$) 
          -- ($($(swick-open#1.base)!\pgfkeysvalueof{/simplerwick/cut ratio}!(swick-close#1.base)$) + (0,3pt -1*\swick@offset) + #1*(0, -1*\swick@sep)$) 
\else         
    \draw ($(swick-open#1.south) + (0, -1pt)$) 
          -- ($(swick-open#1.base) + (0,3pt -1*\swick@offset) + #1*(0, -1*\swick@sep)$) 
          -- ($(swick-close#1.base) + (0,3pt -1*\swick@offset) + #1*(0, -1*\swick@sep)$) 
          -- ($(swick-close#1.south) + (0,-1pt)$);
\fi}
  \tikzexternalenable}
\makeatother
\begin{document}
\begin{equation}
  \wick{\c1 \phi \c2 \psi A \c2 \psi \c1 \phi}
\end{equation}
\begin{equation}
  \wick[cut]{\c1 \phi \c2 \psi A \c2 \psi \c1 \phi}
\end{equation}
\begin{equation}
  \wick[cut,cut ratio=0.7]{\c1 \phi \c2 \psi A \c2 \psi \c1 \phi}
\end{equation}
\end{document}

在此处输入图片描述

答案2

simplewick包确实非常简单,因此从其代码中生成新命令来执行您想要的操作并不困难。以下是在右侧缩写上打开\arcontraction\brcontraction。如果您还需要在左侧缩写上打开,那么您可以执行类似的命令,注释掉左侧竖线。的语法simplewick有些麻烦,所以我更倾向于采用所描述的方法这里如果我自己实现这个功能。

\documentclass{article}

\usepackage{simplewick}
\makeatletter
\newcommand\brcontraction[5][1ex]{%
  \mathchoice
    {\brcontraction@\displaystyle{#2}{#3}{#4}{#5}{#1}}%
    {\brcontraction@\textstyle{#2}{#3}{#4}{#5}{#1}}%
    {\brcontraction@\scriptstyle{#2}{#3}{#4}{#5}{#1}}%
    {\brcontraction@\scriptscriptstyle{#2}{#3}{#4}{#5}{#1}}}
\newcommand{\brcontraction@}[6]{%
  \setbox\swb@xone=\hbox{${}#1{}#2{}$}%
  \setbox\swb@xtwo=\hbox{${}#1{}#3{}$}%
  \setbox\swb@xthree=\hbox{${}#1{}#4{}$}%
  \setbox\swb@xfour=\hbox{${}#1{}#5{}$}%
  \swdimen@ne=\wd\swb@xtwo%
  \advance\swdimen@ne by \wd\swb@xfour%
  \divide\swdimen@ne by 2%
  \advance\swdimen@ne by \wd\swb@xthree%
  \lower 0.5ex \vbox{%
    \hbox to 0pt{%
      \kern \wd\swb@xone%
      \kern 0.5\wd\swb@xtwo%
      \brcontraction@@{\swdimen@ne}{#6}%
      \hss}%
    }}    
\newcommand{\brcontraction@@}[3][0.05em]{%
  \hbox{%
    \swdimentw@=#3
    \advance\swdimentw@ by -#1
    \vrule width #1 height 0pt depth #3%
    \lower\swdimentw@\hbox{\vrule width #2 height 0pt depth #1}%
%    \vrule width #1 height 0pt depth #3% commented out from original code
    \relax}}
\newcommand{\brcontracted}[5][1ex]{%
  \brcontraction[#1]{#2}{#3}{#4}{#5}\ensuremath{#2#3#4#5}}
\newcommand{\arcontraction}[5][1ex]{%
  \mathchoice
    {\arcontraction@\displaystyle{#2}{#3}{#4}{#5}{#1}}%
    {\arcontraction@\textstyle{#2}{#3}{#4}{#5}{#1}}%
    {\arcontraction@\scriptstyle{#2}{#3}{#4}{#5}{#1}}%
    {\arcontraction@\scriptscriptstyle{#2}{#3}{#4}{#5}{#1}}}%
\newcommand{\arcontraction@}[6]{%
  \setbox\swb@xone=\hbox{${}#1{}#2{}$}%
  \setbox\swb@xtwo=\hbox{${}#1{}#3{}$}%
  \setbox\swb@xthree=\hbox{${}#1{}#4{}$}%
  \setbox\swb@xfour=\hbox{${}#1{}#5{}$}%
  \swdimen@ne=\wd\swb@xtwo%
  \advance\swdimen@ne by \wd\swb@xfour%
  \divide\swdimen@ne by 2%
  \advance\swdimen@ne by \wd\swb@xthree%
  \vbox{%
    \hbox to 0pt{%
      \kern \wd\swb@xone%
      \kern 0.5\wd\swb@xtwo%
      \arcontraction@@{\swdimen@ne}{#6}%
      \hss}%
    \vskip 0.5ex%  how far above the line starts
    \vskip\ht\swb@xtwo}}
\newcommand{\arcontraction@@}[3][0.05em]{%
  \hbox{%
    \vrule width #1 height 0pt depth #3%
    \vrule width #2 height 0pt depth #1%
%    \vrule width #1 height 0pt depth #3% commented out from original code
    \relax}}
\newcommand{\arcontracted}[5][1ex]{%
  \arcontraction[#1]{#2}{#3}{#4}{#5}\ensuremath{#2#3#4#5}}
\begin{document}

\[
\arcontraction[2ex]{}{A}{B}{C}
\arcontraction{A}{B}{C}{D}
ABCD\dots
\]
\[
\brcontraction[2ex]{}{A}{B}{C}
\brcontraction{A}{B}{C}{D}
ABCD\dots
\]

\[
\brcontraction[2ex]{\sum n[}{A}{BC}{D}
\brcontraction{\sum n[A}{B}{C}{D}
\sum n[\hat{A}\hat{B}\hat{C}\hat{D}\dots]
\]

\end{document}

代码输出

相关内容