我在学习 Latex 方面取得了很大的进步。但是,我遇到了一个问题。我无法使用以下代码更改序列图的尺寸:我使用了\usepackage{pgf-umlsd}
包。此外,当我尝试使用它时\centering
,它没有任何影响。任何帮助都将不胜感激。
\begin{sequencediagram}
\newthread{customer}{:Customer}
\newinst[1]{merchant}{:Merchant}
\newinst[1]{ds}{Directory Server}
\newinst[1]{acs}{:ACS}
\begin{call}{customer}{Pay}{merchant}{Accept}
\begin{call}{merchant}{rule=auth}{merchant}{activate3ds()}\end{call}
\begin{call}{merchant}{3DS Versioning}{ds}{Invoke ID Call}\end{call}
\begin{sdblock}{tunnel}{Device Fingerprint}
\begin{mess}{customer}{connect ACS}{acs}\end{mess}
\begin{call}{acs}{Request Device Information}{customer}
{deviceInfo()}\end{call}
\end{sdblock}
\begin{call}{merchant}{AuthReq}{ds}{AuthResp}
\begin{call}{ds}{AuthReq}{acs}{AuthResp}\end{call}
\end{call}
\end{call}
\end{sequencediagram}
答案1
pgf-umlsd
使用宏\unitfactor
来设置图表中的垂直间距。默认值为 0.6。您可以在环境中重新定义该宏sequencediagram
。
\tikzset{every picture/.append style={transform shape,scale=<scalefactor>}}
另一个选项是在之前使用sequencediagram
。最好在组内执行此操作,以便它仅适用于图表。在下面的示例中,center
环境形成一个组,因此将该设置保持在本地。
至于您对 的评论\centering
,如果您不展示使用它的方式,就不可能说出为什么它不起作用。
\documentclass{article}
\usepackage{pgf-umlsd}
\begin{document}
\begin{center}
\begin{sequencediagram}
% the default unitfactor is 0.6
% adjust up or down to change y-scale
\renewcommand\unitfactor{0.6}
\newthread{customer}{:Customer}
\newinst[1]{merchant}{:Merchant}
\newinst[1]{ds}{Directory Server}
\newinst[1]{acs}{:ACS}
\begin{call}{customer}{Pay}{merchant}{Accept}
\begin{call}{merchant}{rule=auth}{merchant}{activate3ds()}\end{call}
\begin{call}{merchant}{3DS Versioning}{ds}{Invoke ID Call}\end{call}
\begin{sdblock}{tunnel}{Device Fingerprint}
\begin{mess}{customer}{connect ACS}{acs}\end{mess}
\begin{call}{acs}{Request Device Information}{customer}{deviceInfo()}\end{call}
\end{sdblock}
\begin{call}{merchant}{AuthReq}{ds}{AuthResp}
\begin{call}{ds}{AuthReq}{acs}{AuthResp}\end{call}
\end{call}
\end{call}
\end{sequencediagram}
\end{center}
\begin{center}
\tikzset{
% add this style to all tikzpicture environments
every picture/.append style={
% enable scaling of nodes
transform shape,
% set scale factor
scale=1
}
}
\begin{sequencediagram}
\newthread{customer}{:Customer}
\newinst[1]{merchant}{:Merchant}
\newinst[1]{ds}{Directory Server}
\newinst[1]{acs}{:ACS}
\begin{call}{customer}{Pay}{merchant}{Accept}
\begin{call}{merchant}{rule=auth}{merchant}{activate3ds()}\end{call}
\begin{call}{merchant}{3DS Versioning}{ds}{Invoke ID Call}\end{call}
\begin{sdblock}{tunnel}{Device Fingerprint}
\begin{mess}{customer}{connect ACS}{acs}\end{mess}
\begin{call}{acs}{Request Device Information}{customer}{deviceInfo()}\end{call}
\end{sdblock}
\begin{call}{merchant}{AuthReq}{ds}{AuthResp}
\begin{call}{ds}{AuthReq}{acs}{AuthResp}\end{call}
\end{call}
\end{call}
\end{sequencediagram}
\end{center}
\end{document}