我想对齐文本框并在它们之间绘制箭头。我目前的尝试如下:
\documentclass[crop,tikz]{standalone}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{minipage}[t]{\textwidth}
\begin{tcolorbox}[colback=white, boxrule=0pt, width=\textwidth]
$\quad$\textbf{Work package overview:}
\end{tcolorbox}
\begin{minipage}[t]{\textwidth}
\begin{tcolorbox}[colback=white, colframe=black, arc=0pt, outer arc=0pt, width=\textwidth, remember as=ci]
test
\end{tcolorbox}
\end{minipage}
\begin{minipage}[t]{0.495\textwidth}
\begin{tcolorbox}[colback=white, colframe=black, arc=0pt, outer arc=0pt, width=\textwidth]
First text box
\end{tcolorbox}
\end{minipage}
\hfill
\begin{minipage}[t]{0.495\textwidth}
\begin{tcolorbox}[colback=white, colframe=black, arc=0pt, outer arc=0pt, width=\textwidth, remember as=adm]
Second text box\\
test
\end{tcolorbox}
\end{minipage}
\begin{minipage}[t]{\textwidth}
\begin{tcolorbox}[colback=white, colframe=black, arc=0pt, outer arc=0pt, width=\textwidth]
test
\end{tcolorbox}
\end{minipage}
\end{minipage}
\end{document}
结果几乎看起来正确,但如果一个框在垂直方向上比另一个框长,则它应该与相邻框的顶部边框对齐,而不是底部边框。
我希望能够对彼此相邻以及彼此上下的可变数量的盒子执行此操作。
箭头应该有点像这样:
箭头以及与remember as
(和enhanced
?) 一起使用时产生了一些奇怪的结果。但 tikz 箭头无法识别。
答案1
使用 tcolorboxs 而不是 tikz 节点似乎很奇怪,但是你可以这样做:
- 对于顶部对齐,请参阅 tex.stackexchange.com/a/712457/36296
- 有关添加箭头,请参阅 tex.stackexchange.com/a/391066/36296
\documentclass[crop]{standalone}
\usepackage{tikz}
\usetikzlibrary{ext.paths.ortho}
\usepackage[most]{tcolorbox}
\tcbset{enhanced}
\begin{document}
\noindent\begin{minipage}[t]{\textwidth}
\begin{tcolorbox}[colback=white, boxrule=0pt, width=\textwidth,box align=top]
$\quad$\textbf{Work package overview:}
\end{tcolorbox}
\begin{minipage}[t]{\textwidth}
\begin{tcolorbox}[colback=white, colframe=black, arc=0pt, outer arc=0pt, width=\textwidth, remember as=ci,box align=top,remember as=NodeName1]
test
\end{tcolorbox}
\end{minipage}
\begin{minipage}[t]{0.495\textwidth}
\begin{tcolorbox}[colback=white, colframe=black, arc=0pt, outer arc=0pt, width=\textwidth,box align=top]
First text box
\end{tcolorbox}
\end{minipage}
\hfill
\begin{minipage}[t]{0.495\textwidth}
\begin{tcolorbox}[colback=white, colframe=black, arc=0pt, outer arc=0pt, width=\textwidth, remember as=adm,box align=top,remember as=NodeName2]
Second text box\\
test
\end{tcolorbox}
\end{minipage}
\begin{minipage}[t]{\textwidth}
\begin{tcolorbox}[colback=white, colframe=black, arc=0pt, outer arc=0pt, width=\textwidth,box align=top]
test
\end{tcolorbox}
\end{minipage}
\end{minipage}\hspace{1cm}
\begin{tikzpicture}[remember picture,overlay]
\draw[red,->,ultra thick] (NodeName1.east) -|-[distance=1cm] (NodeName2.east);
\end{tikzpicture}
\end{document}