我需要在下面的例子中放置三个文本框:
\documentclass[12pt]{article}
\usepackage{expex}
\usepackage{tikz}
\usepackage{xparse}
\newcommand\Tikzmark[2]{%
\tikz[remember picture]\node[inner sep=0pt,outer sep=0pt] (#1) {#2};}
\NewDocumentCommand\DrawArrow{O{}mmmmO{3}}{
\tikz[remember picture,overlay]
\draw[-,line width=0.5pt,shorten >= 2pt,shorten <= 2pt,#1]
(#2) -- ++(0,-#6\ht\strutbox) coordinate (aux) -- node[#4] {#5} (#3|- aux) -- (#3);}
\begin{document}
\pex \rightcomment{Engl}
\a\Tikzmark{enda}{H}e {} {} {} {} {} {} {} br\Tikzmark{starta} {o}\Tikzmark{endb}{k}e {} {} {} {} {} t\Tikzmark{startb}{h}e c\Tikzmark{endc}{a}r {} {} {} {} {} {} \textsc{ye\Tikzmark{startc}{s}terday} ]
\DrawArrow{starta}{enda}{midway, fill=white}{\scshape x}
\DrawArrow{startb}{endb}{midway, fill=white}{\scshape y}
\DrawArrow{startc}{endc}{midway, fill=white}{\scshape z}
\\
\\
\a \DrawArrow{startc}{enda}{midway, fill=white}{\scshape w}[6]
\xe
\end{document}
这三个框需要位于 Y、Z、W 的正下方。有人可以建议我怎么做吗?
谢谢你!
答案1
您需要确保底部框的内容适合空间,因为它不会修改底层图形的位置。
我介绍了\uderbox{<label>}{<under text>}
,您可以根据自己的需要进行定制。
\documentclass[12pt]{article}
\usepackage{expex}
\usepackage{tikz}
\usepackage{xparse}
\usepackage{stackengine}
\renewcommand\useanchorwidth{T}
\newcommand\Tikzmark[2]{%
\tikz[remember picture]\node[inner sep=0pt,outer sep=0pt] (#1) {#2};}
\NewDocumentCommand\DrawArrow{O{}mmmmO{3}}{
\tikz[remember picture,overlay]
\draw[-,line width=0.5pt,shorten >= 2pt,shorten <= 2pt,#1]
(#2) -- ++(0,-#6\ht\strutbox) coordinate (aux) -- node[#4] {#5} (#3|- aux) -- (#3);}
\newcommand\underbox[2]{\vphantom{#1}\smash{\stackunder[5pt]{\scshape #1}{%
\fboxsep=1pt\scriptsize\fbox{#2}}}}
\begin{document}
\pex \rightcomment{Engl}
\a\Tikzmark{enda}{H}e {} {} {} {} {} {} {} br\Tikzmark{starta} {o}\Tikzmark{endb}{k}e {} {} {} {} {} t\Tikzmark{startb}{h}e c\Tikzmark{endc}{a}r {} {} {} {} {} {} \textsc{ye\Tikzmark{startc}{s}terday} ]
\DrawArrow{starta}{enda}{midway, fill=white}{\scshape x}
\DrawArrow{startb}{endb}{midway, fill=white}{\underbox{\scshape y}{Hi, Mom}}
\DrawArrow{startc}{endc}{midway, fill=white}{\underbox{\scshape z}{!!@\#}}
\\
\\
\a \DrawArrow{startc}{enda}{midway, fill=white}{\underbox{\scshape w}{And now, for something completely different.}}[6]
\xe
\end{document}