我正在尝试制作一个单词关联图,其中包含一个单词表,这些单词具有相似的分组,并用圆角矩形标记这些分组。这也需要能够像下面的示例 2 中那样进行对角线绘制。这可以在 latex 中完成吗?
多谢。
答案1
运行xelatex
\documentclass[]{article}
\usepackage{pst-node}
\begin{document}
\begin{psmatrix}[colsep=1cm, rowsep=1cm]
A1& B1& C1& D1 \\
A2& B2& C2& D2 \\
A3& B3& C3& D3 \\
A4& B4& C4& D4
\end{psmatrix}
\ncbox[linecolor=blue,nodesep=5pt,linearc=0.4]{2,1}{1,2}
\ncarcbox*[linecolor=yellow,nodesep=5pt,linearc=0.4,arcangle=50,opacity=0.4]{2,2}{3,4}
\ncbox[linecolor=red,nodesep=5pt,linearc=0.4]{2,3}{4,4}
\end{document}
如果你需要曲线那么看这里: http://tug.org/PSTricks/main.cgi?file=Lines/lines#curves
答案2
这是一种使用矩阵节点的方法
代码
\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows}
\begin{document}
\begin{tikzpicture}%[thick]
\matrix (mat) [%
matrix of nodes, column sep=1cm, row sep=1cm
]
{%
A1& B1& C1& D1 \\
A2& B2& C2& D2 \\
A3& B3& C3& D3 \\
A4& B4& C4& D4 \\
};
\draw[blue,very thick, rounded corners] (mat-2-1.north west) --(mat-1-2.north west) -| (mat-1-2.south east)-- (mat-2-1.south east) -| (mat-2-1.north west);
\draw[yellow,very thick] (mat-2-2.north west) -| (mat-2-2.south east) -- (mat-3-2.south east) -- (mat-3-2.south west) --(mat-2-2.north west);
\draw[green,very thick] (mat-1-3.north west) -| (mat-1-3.south east) -- (mat-2-3.south east) -- ++(0,-0.5cm) -| (mat-1-3.north west);
\draw[red,very thick] (mat-2-3.north west) -| (mat-2-4.north east) -- (mat-2-4.south east) -- (mat-2-3.south west)-- ++(-0.5cm,0) |-(mat-2-3.north west);
\end{tikzpicture}
\end{document}