tikzmarknode
与字符组合占用vphantom
水平空间。虽然很小,但仍然引人注目。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
Text \tikzmarknode{a}text
Text \tikzmarknode{b}text
\begin{tikzpicture}[remember picture,overlay] \draw (a.west) -- (b.west); \end{tikzpicture}
Text \tikzmarknode{a}{\vphantom{t}}text
Text \tikzmarknode{b}{\vphantom{t}}text
\begin{tikzpicture}[remember picture,overlay] \draw (a.west) -- (b.west); \end{tikzpicture}
\end{document}
有人能解释一下原因吗?有没有办法可以防止这种情况发生,或者至少找出确切的空间,以便我可以以某种方式修复它?
答案1
问题是minimum width
它的值为 1pt(文档在这里似乎是错误的)。tikzmark 可能应该在 \tikzmarknode 中将其设置为 0pt,并提交错误报告。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\tikzset{every tikzmarknode/.style={minimum width=0pt}}
\begin{document}
\pgfkeysvalueof{/pgf/minimum width}
Text \tikzmarknode{a}text
Text \tikzmarknode{b}text
\begin{tikzpicture}[remember picture,overlay] \draw (a.west) -- (b.west); \end{tikzpicture}
Text \tikzmarknode{a}{\vphantom{t}}text
Text \tikzmarknode{b}{\vphantom{t}}text
\begin{tikzpicture}[remember picture,overlay] \draw (a.west) -- (b.west); \end{tikzpicture}
\end{document}