![如何编辑此图形,使其只在一列或两列的纸张上绘制?](https://linux22.com/image/391113/%E5%A6%82%E4%BD%95%E7%BC%96%E8%BE%91%E6%AD%A4%E5%9B%BE%E5%BD%A2%EF%BC%8C%E4%BD%BF%E5%85%B6%E5%8F%AA%E5%9C%A8%E4%B8%80%E5%88%97%E6%88%96%E4%B8%A4%E5%88%97%E7%9A%84%E7%BA%B8%E5%BC%A0%E4%B8%8A%E7%BB%98%E5%88%B6%EF%BC%9F.png)
下面的代码使输出图形占满整个页面宽度。我需要输出与列宽相同的图形(宽度为 3.9 英寸)。
我尝试使用此命令来绘制以下代码生成的图形
\includegraphics[width=0.45\textwidth]{figures/selection.pdf}
,但图片相对较小,文本大小不可读,如下图所示。如何使用 tkiz 包绘制相同的协议,但在 2 列纸张的列宽内,并且里面有可读的文本?
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{positioning,calc,arrows.meta}
\begin{document}
\begin{tikzpicture}[%
block/.style={rectangle, draw, fill=blue!10, text width=5em, text centered,
rounded corners},line/.style={draw, -latex},arrow/.style={draw, -latex}]
\node[block,text width=3.cm, align=center,font=\bfseries](man) at (0,0){Device A};
\node[block,text width=3cm,right=5cm of man, align=center,font=\bfseries](smart) {Device B};
\node[block,text width=3cm,right=5cm of smart,align=center,font=\bfseries](recv) {Device C};
\path[line, line width=0.5mm] (man.south) -- ($(man)+(0,-8)$);
\path[line, line width=0.5mm] (smart.south) -- ($(smart)+(0,-8)$);
\path[line, line width=0.5mm] (recv.south) -- ($(recv)+(0,-8)$);
\path [arrow, text width=4.5cm, align=left] ($(man)+(0,-0.5)$) -- ++(0.5cm,0cm) |- node[near start, right] {
\begin{tabular}{ll}
Computes & $G^R_0= M^R_0$ \\ Computes & $G^R_n = l^R_n$\\ Picks & $I^R_0 = t^R_0$
\end{tabular}} ($(man)+(0,-1.7)$);
\draw[-{Latex[length=3mm, width=2mm]}] ($(man)+(0,-3)$) to node [above, black]{$T(R)=X^R_0, X^R_0, Y^R_d $} ($(smart)+(0,-3)$);
\path [arrow, text width=4.5cm, align=left] ($(recv)+(0,-1.5)$) -- ++(0.5cm,0cm) |- node[near start, right]
{\begin{tabular}{ll}
Picks & $Z^R_0 \leftarrow l^R_0$ \\
computes & $Z^R_n \leftarrow l^R_n$\\
& $I^R_0 \leftarrow t^R_0$
\end{tabular}} ($(recv)+(0,-2.9)$);
\draw[-{Latex[length=3mm, width=2mm]}] ($(recv)+(0,-3.8)$) to
node[above, black]{$S^{D_1}_0, S^{D_1}_n, t^{D_1}_0, t^{M_1}_n, F_{M_1}$} ($(smart)+(0,-3.8)$);
\path [arrow, text width=4.5cm, align=left] ($(smart)+(0,-4.5)$)
-- ++(0.5cm,0cm) |- node[near start, right] {
\begin{tabular}{ll}
Picks & $Z^R_0 \leftarrow l^R_0$ \\
computes & $Z^R_n \leftarrow l^R_n$\\
& $I^R_0 \leftarrow t^R_0$
\end{tabular}} ($(smart)+(0,-5.9)$);
\end{tikzpicture}
\end{document}
请注意:这个很好的答案来自有没有一种有效的方法来编辑以下 UML
答案1
尝试
\includegraphics[width=\columnwidth]{figures/selection.pdf}
并设置在standalone
图像中border=0pt
。
如果您提供文档示例(带有虚拟文本),我将能够测试如何在您的文档中对图像代码进行以下改进:
\documentclass[tikz,border=0pt]{standalone}
\usetikzlibrary{arrows.meta, calc, positioning, quotes}
\begin{document}
\begin{tikzpicture}[
node distance = 3mm and 17mm,
block/.style = {draw, rounded corners, fill=blue!10,
font=\bfseries},
line/.style = {line width=0.5mm, -Latex},
arrow/.style = {draw, -Latex}
]
\node (man) [block] {Device A};
\node (smart) [block,right=of man] {Device B};
\node (recv) [block,right=of smart] {Device C};
%
\draw[line] (man.south) edge ++ (0,-6.6)
(smart.south) edge ++ (0,-6.6)
(recv.south) to ++ (0,-6.6);
%
\draw[arrow]
($(man)+(0,-0.5)$) -- ++(0.4,0)
|- node[near start, right] {\begin{tabular}{@{} l @{\ }l@{}}
Computes & $G^R_0= M^R_0$ \\
Computes & $G^R_n = l^R_n$\\
Picks & $I^R_0 = t^R_0$
\end{tabular} }
($(man)+(0,-1.7)$);
\draw[arrow,thick]
($(man)+(0,-3)$) to ["${T(R)=X^R_0, X^R_0, Y^R_d}$"] ($(smart)+(0,-3)$);
\draw[arrow,thick]
($(recv)+(0,-3.8)$) to ["${S^{D_1}_0, S^{D_1}_n, t^{D_1}_0, t^{M_1}_n, F_{M_1}}$" '] ($(smart)+(0,-3.8)$);
\draw[arrow]
($(recv)+(0,-1.5)$) -- ++(0.4,0)
|- node[near start, right] {\begin{tabular}{@{} l @{\ }l@{}}
Picks & $Z^R_0 \leftarrow l^R_0$ \\
Computes & $Z^R_n \leftarrow l^R_n$\\
& $I^R_0 \leftarrow t^R_0$
\end{tabular}}
($(recv)+(0,-2.9)$);
\path[arrow]
($(smart)+(0,-4.5)$) -- ++(0.4cm,0cm)
|- node[near start, right] {\begin{tabular}{@{} l @{\ }l@{}}
Picks & $Z^R_0 \leftarrow l^R_0$ \\
Computes & $Z^R_n \leftarrow l^R_n$\\
& $I^R_0 \leftarrow t^R_0$
\end{tabular}}
($(smart)+(0,-5.9)$);
\end{tikzpicture}
\end{document}
宽度约为113毫米。