答案1
您可以使用以下-|
语法:
\documentclass[11pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[draw] (A)at (0,0) {\rule{0pt}{3cm}A} ;
\node[draw] (B) at (3,0) {\rule{0pt}{5cm}B} ;
\coordinate (C) at ([shift={(-1,3)}]A.north west);
\coordinate (Dx) at([xshift={1cm}]B.north east);
\draw (C)node[left]{C} -- (C -| Dx)node[right]{D};
\end{tikzpicture}
\end{document}