下面的程式碼使輸出圖形為全頁寬度。我需要具有與列寬度(寬度為 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
image中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}
寬度約為113mm。