1

I am using the MSC package for sequence diagrams. I need to make a multiple-lines right-side comment. I tried to add \\ but this result in error. This is the minimal script and you need the package file.

\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}

I saw a similar problem here but the solution posted here does not work at all. It result in error. Can you please try my example and help my resolve the problem.

EDIT: After removing the msc.sty file from the directory where the .tex file is located, I got this error:

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.

EDIT 2: Package link updated to the new version.

  • 1
    Could you please make your code compilable? For instance, \resizebox requires an additional package such as graphicx. But even if this is fixed, the code does not run through. – user121799 Dec 10 '17 at 19:36
  • You need to download msc.sty and put it in the Latex project directory. I included the package link. It runs with me exactly as I posted. The only difference I have the msc.sty file. – user6875880 Dec 10 '17 at 19:52
  • 1
    I don't think so, it is part of the texlive distribution. Or are you saying that you're using a style file that is different from the one in the texlive distribution, but carries the same name? – user121799 Dec 10 '17 at 19:56
  • 1
    Well, if I follow the link you provide, I read "contained in MikTeX as msc" and "contained in texlive as msc". It is definitely not recommended to load the style files into your project directory. Rather, you should use it as it is provided by your distribution. This will drastically increase your chances of getting some help in this forum. – user121799 Dec 10 '17 at 20:19
  • 1
    Oh yes, that's very reminiscent of the errors I obtain. You may find it annoying to go through this here, but the packages get regularly updated and made compatible with each other. This is major effort for those providing them for free. So you may understand that it is your responsibility to use one consistent distribution rather than mixing style files from different installations. Now I strongly recommend that you fix the errors by including the graphicx package and reading the msc package distribution, – user121799 Dec 10 '17 at 20:34
1

If you use the development version of msc.sty, where the author has rewritten the entire thing to use TikZ instead of pstricks, you can modify the every msccomment style to include a text width setting. This makes the node a minipage like box of the defined width, and line breaking is automatic.

output of code

\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}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.