在 tikzcd 中,我知道“description”限定符,它将带有白色背景的节点放置在箭头的顶部和中间。如何在 tikz 中最好地实现这一点?
答案1
midway
和above
\documentclass[margin=2pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[->](0,0)--(2,0) node[midway,above]{label}; %if you want to enforce a white background add fill=white to the node options
\end{tikzpicture}
\end{document}
第二次尝试:
\documentclass[margin=2pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[->](0,0)--(2,0) node[midway,fill=white]{label}; %for better vertical alignment you can add text height=.5em to the node options or a \strut inside the node text
\end{tikzpicture}
\end{document}