下面\MyTikzMarkNode
的代码似乎在数学模式下插入了额外的水平空间。应该如何定义宏才能消除额外的水平空间?
代码:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\MyTikzMarkNode}[2]{\tikz[remember picture,baseline]\node[anchor=base](#1){#2};}%
\begin{document}
\begin{align*}
E &= mc^2 \\
F &= \MyTikzMarkNode{Node Name 1}{$ma$}\MyTikzMarkNode{Node Name 2}{$ma$}
\end{align*}
\end{document}
答案1
您观察到的空间是节点内容与其边界内部分离的结果。如果您向节点选项添加“inner xsep=0pt”,则此空间将消失:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\MyTikzMarkNode}[2]{\tikz[remember picture,baseline]\node[anchor=base,
inner xsep=0pt% by this the horizontal space beteen nodes disapear
](#1){#2};}%
\begin{document}
\MyTikzMarkNode{Node Name 1}{$ma$}\MyTikzMarkNode{Node Name 2}{$ma$}
\begin{align*}
E &= mc^2 \\
F &= \MyTikzMarkNode{Node Name 1}{$ma$}\MyTikzMarkNode{Node Name 2}{$ma$}
\end{align*}
\end{document}