\mscomment 中需要多行

\mscomment 中需要多行

我正在使用MSC 包用于序列图。我需要添加多行右侧注释。我尝试添加,\\ 但结果出错。这是最小脚本,您需要包文件。

\documentclass[10pt]{article}
\usepackage{msc} %for the diagrams


\begin{document}
\title{Title Here}
\maketitle

\begin{figure}[!tp] 
\centering
\resizebox{\columnwidth}{!}{
\setmsckeyword{} %removes msc keyword from the title
\drawframe{no} %no frame

\begin{msc}[normal values, /msc/level height=0.6cm, /msc/label distance=0.5ex , /msc/first level height=0.6cm, /msc/last level height=0.6cm, /msc/top head dist=0, /msc/bottom foot dist=0]{}
\setlength{\instwidth}{2.5\mscunit} 
\setlength{\instdist}{4\mscunit} %message width

\declinst{A}{}{A}
\declinst{B}{}{B}
\declinst{C}{}{C}

\mess {Message 1)}{A}{B}
\mess {Message1}{B}{C}
\nextlevel

\mess {Message2}{B}{C}
\nextlevel
\msccomment[msccomment distance=1cm, side=right]{Very long comment here I need multiple lines}{C}

\end{msc}
} %end scalebox
\end{figure}
\end{document}

我看到了类似的问题这里但这里发布的解决方案根本不起作用。它导致错误。你能尝试我的示例并帮助我解决问题吗?

编辑:msc.sty从文件所在的目录中 删除该文件后.tex,出现此错误:

main.tex(11): Error: Undefined control sequence.
main.tex(11): Error: Missing number, treated as zero.
main.tex(11): Error: Illegal unit of measure (pt inserted).
: ''(29): Error: Missing number, treated as zero.
: ''(29): Error: Illegal unit of measure (pt inserted).
: ''(29): Error: Package calc Error: `m' invalid at this point.
: ''(31): Error: Package msc Error: illegal title placement specifier: normal values, /msc/level height=0.6cm, /msc/label distance=0.5ex , /msc/first level height=0.6cm, /msc/last level height=0.6cm, /msc/top head dist=0, /msc/bottom foot dist=0.
: ''(31): Error: Undefined control sequence.
: ''(31): Error: Extra }, or forgotten \endgroup.
: ''(31): Error: Missing } inserted.
main.tex(31): Error: LaTeX Error: \begin{lrbox} on input line 15 ended by \end{msc}.
main.tex(32): Error: Extra }, or forgotten \endgroup.
main.tex(33): Error: Extra }, or forgotten \endgroup.
main.tex(33): Error: Missing } inserted.
main.tex(34): Error: LaTeX Error: \begin{figure} on input line 9 ended by \end{document}.
main.tex(34): Error: You can't use `\end' in internal vertical mode.
main.tex(34): Error: LaTeX Error: \begin{figure} on input line 9 ended by \end{document}.
main.tex(34): Error: Missing } inserted.

编辑2: 软件包链接已更新至新版本。

答案1

如果您使用 的开发版本msc.sty,其中作者已将整个内容重写为使用 TikZ 而不是pstricks,您可以修改every msccomment样式以包含text width设置。这使节点成为minipage定义宽度的类似框,并且自动换行。

代码输出

\documentclass[10pt]{article}
\usepackage{msc} %for the diagrams
\begin{document}

\begin{figure}[!tp] 
\centering
\setmsckeyword{} %removes msc keyword from the title
\drawframe{no} %no frame

\begin{msc}[
  normal values,
  /msc/level height=0.6cm,
  /msc/label distance=0.5ex,
  /msc/first level height=0.6cm,
  /msc/last level height=0.6cm,
  /msc/top head dist=0,
  /msc/bottom foot dist=0
]{}

\setlength{\instwidth}{2\mscunit} 
\setlength{\instdist}{2\mscunit} %message width

\declinst{A}{}{A}
\declinst{B}{}{B}
\declinst{C}{}{C}

\mess {Message 1)}{A}{B}
\mess {Message1}{B}{C}
\nextlevel

\mess {Message2}{B}{C}
\nextlevel
\msccomment[%
  msccomment distance=1cm,
  side=right,
  /msc/every msccomment/.append style={
   text width=3cm
  }
  ]{Very long comment here I need multiple lines}{C}

\end{msc}
\end{figure}
\end{document}

相关内容