就像下面的命令
\newcommand\xx[2]{#1#2}

1

  • 2
    您的标题太过笼统,会让未来寻找相同符号的用户难以找到您的帖子。或许可以添加一两个关键字来描述您使用该符号的用途?


    – 


最佳答案
2

这是一个array基于的解决方案。

\documentclass{article}
\usepackage{newtx} % optional (Times Roman text and math fonts)
\usepackage{array}
\newcommand\xx[2]{%  feel free to choose a name other than 'xx'
   \begingroup
   \setlength\arraycolsep{1.5pt} % default: 5pt
   \begin{array}{@{}r|l@{}} 
     \cline{2-2} #1&#2 \\ \cline{1-1}
   \end{array}
   \endgroup}

\begin{document}
$b_1-\xx{1}{b_2}-\ldots-\xx{1}{b_s}$
\end{document}

两个版本,一个带有tabularray,第二个带有TiKz

\documentclass{article}
\usepackage{tabularray}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}

\newcommand{\xx}[2]{\begin{tblr}{
      colspec={r|l},
      column{1} = {leftsep=0pt,rightsep=3pt},
      column{2} = {leftsep=3pt,rightsep=0pt},
      row{1} = {abovesep=1pt,belowsep=1pt},
  }
    \cline{2-2}
    \ensuremath{#1} & \ensuremath{#2}\\
    \cline{1-1}
  \end{tblr}}

\newcommand{\xxx}[2]{\begin{tikzpicture}[baseline=(a.base),inner sep=2pt, outer sep=0pt, node distance=6pt]
    \node (a) at (0,0) {\ensuremath{#1}};
    \node [right=of a] (b) {\ensuremath{#2}};
    \draw[very thin] ($(a.south west)-(2pt,0)$) -| ($(a)!.5!(b)$) |- ($(b.north east)+(2pt,0)$);
\end{tikzpicture}}

\begin{document}
  
  \xx{a}{b}
  
  \begin{equation}
    b_1-\xx{1}{b_2}-\ldots-\xx{1}{b_s}
  \end{equation}
  
  \xxx{a}{b}
  
  \begin{equation}
    b_1-\xxx{1}{b_2}-\ldots-\xxx{1}{b_s}
  \end{equation}
\end{document}

请随意调整参数;)


编辑

为了处理参数中的分数,我调整了 TiKz 版本:

\documentclass{article}
\usepackage{tabularray}
\usepackage{tikz}
\usetikzlibrary{calc,fit,positioning,tikzmark}

\newcommand{\xx}[2]{\begin{tblr}{
      colspec={Q[r,m]|Q[l,m]},
      column{1} = {leftsep=0pt,rightsep=3pt},
      column{2} = {leftsep=3pt,rightsep=0pt},
      row{1} = {abovesep=1pt,belowsep=1pt},
  }
    \cline{2-2}
    \ensuremath{#1} & \ensuremath{#2}\\
    \cline{1-1}
  \end{tblr}}

\newcommand{\xxx}[2]{\begin{tikzpicture}[baseline=(O.base),inner sep=2pt, outer sep=0pt, node distance=6pt]
\coordinate (O) at (0,0);
\node [anchor=base] (a) at (O) {\ensuremath{#1}};
\node [right=of a, anchor=base] (b) {\ensuremath{#2}};
\draw[very thin] ($(a.south west)-(2pt,0)$) -| ($(a)!.5!(b)$) |- ($(b.north east)+(2pt,0)$);
\end{tikzpicture}}

\newcommand{\xxxx}[2]{\begingroup
  \tikzmarknode{a}{#1}\,
  \tikzmarknode{b}{#2}
  \begin{tikzpicture}[remember picture, overlay,inner sep=2pt, outer sep=0pt, node distance=6pt]
    \node (c) [fit=(a) (b)]{};
    \draw[very thin] ($(c.south west)-(2pt,0)$) -| ($(a.east)!.5!(b.west)$) |- ($(c.north east)+(2pt,0)$);
  \end{tikzpicture}
  \endgroup}

\begin{document}
  With \verb|tabularray|
  \begin{equation}
    b_1-\xx{1}{\frac{b_2}{\frac{b_1}{b_2}}}-\ldots-\xx{\frac{1}{2\frac{1}{2\frac{1}{2}}}}{b_s}
  \end{equation}
  
  With \verb|TiKz|
  \begin{equation}
    b_1-\xxx{\frac{1}{2}}{\frac{b_2}{\frac{b_1}{b_2}}}-\ldots-\xxx{1\frac{1}{2\frac{1}{2\frac{1}{2}}}}{b_s}
  \end{equation}
  
  Improving the \verb|TiKz| version
  \begin{equation}
    b_1-\xxxx{1}{\frac{b_2}{\frac{b_1}{b_2}}}-\ldots-\xxxx{1\frac{1}{2\frac{1}{2\frac{1}{2}}}}{b_s}
  \end{equation}
  
\end{document}