答案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}