我试图让顶行的文本像底行的文本一样布局。最终,我需要从彩色的 t 画出指向单词“when”的箭头。我认为像我在代码中所做的那样指定节点是最简单的方法。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[white, text=black] (1,1) node(when){When};
\draw[white, text=black] (when) node[anchor=west](s1){did John say};
\draw[white, text=red] (s1) node[anchor=west](t1){t};
\draw[white, text=black] (t1) node[anchor=west](s2){that Pat was fired};
\draw[white, text=blue] (s2) node[anchor=west](t2){t};
\node (1,-1) {When did John say \textcolor{red}{t} that Pat was fired \textcolor{blue}{t} ?};
\end{tikzpicture}
\end{document}
答案1
\documentclass{article}
\usepackage{tikz}
\newcommand\tikznode[3][]%
{\tikz[remember picture,baseline=(#2.base)]
\node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}
\begin{document}
\begin{itemize}
\item[] \tikznode{PT}When did John say anything
\item[] John never said anything at \tikznode{PB0}all
\end{itemize}
\begin{tikzpicture}[remember picture,overlay,cyan,rounded corners,>=stealth,shorten > =1pt,shorten <=1pt,thick]
\draw[->] (PT)-- +(0,-0.3) -| (PB0);
\end{tikzpicture}
\end{document}