[Tex/LaTex] Run msc package with pdflatex instead of xelatex

auto-pst-pdfpdftexpstricks

I am using msc Latex package for building sequence diagrams, but I can only run it with Xelatex, which I don't like, but apparently it's possible I can use pdflatex if I run it with:

pdflatex -shell-escape <file> option.

But I am using Vim-Latex, and where do I specify this option? I cannot figure this out.

This is my vimrc:

let g:Tex_DefaultTargetFormat='pdf'
function CompileXeTex()
    let oldCompileRule=g:Tex_CompileRule_pdf
    let g:Tex_CompileRule_pdf = 'xelatex -aux-directory=F:/Vim/my_latex_doc/temp --synctex=-1 -src-specials -interaction=nonstopmode $*'
    call Tex_RunLaTeX()
    let g:Tex_CompileRule_pdf=oldCompileRule
endfunction

P.s. This says that with newest msc version all PSTricks dependancies are removed but I downloaded that version, put it instead of old one, but I still get such errors when running with pdflatex:

error| Undefined control sequence. \c@lor@to@ps

So I guess it still depends on PSTricks. Or unless it's not enough to change msc.sty? I just changed the contents of the file to new version.

So my goal is to run this with Pdflatex instead of Xelatex.

My code:

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{eurosym}
\usepackage{wasysym}
\usepackage{todonotes}
\usepackage{geometry}
\usepackage{enumitem}
\usepackage{ulem}
\usepackage{msc}
\usepackage[pdf]{pstricks}
\title{aaa}
\author{aaaaa}

\begin{document}
\normalsize
\maketitle
\tableofcontents
\newpage
\section{In}

\section{aa}
\subsection{}

\begin{center}
\begin{msc}{Deactivate cc}
\setlength{\instdist}{9cm}
\setlength{\envinstdist}{2\envinstdist}
\declinst{cc}{}{C}
\declinst{tt}{}{T}
\nextlevel
\mess{NonceC}{cc}{tt}
\nextlevel[2]
\mess{\{$pu_C$, $[byebye]_{pr_C}\}_{pu_T}$}{cc}{tt}
\end{msc}
\end{center}


\end{document}

EDIT: I added:

let g:Tex_CompileRule_pdf = 'pdflatex -interaction=nonstopmode -shell-escape $*'

to my vimrc as suggested, but I still get PSTricks error:

error| Option clash for package pstricks.

Best Answer

Use it this way: packages which uses PSTricks should not be loaded when running pdflatex and, of course, tikz and todonotes should not be loaded when running latex. My example use the postscript environment:

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{eurosym}
\usepackage{wasysym}
\usepackage{geometry}
\usepackage{enumitem}
\usepackage{ulem}
\usepackage{auto-pst-pdf}
\ifpdf
  \usepackage{todonotes}
  \usepackage{tikz}
  \usetikzlibrary{arrows,automata}
\else
  \usepackage{msc}
\fi
\title{aaa}
\author{aaaaa}

\begin{document}
\maketitle
\tableofcontents
\newpage
\section{In}

\section{aa}
\subsection{b}

\begin{center}
\begin{postscript}
\begin{msc}{Deactivate cc}
\setlength{\instdist}{5cm}
\setlength{\envinstdist}{2\envinstdist}
\declinst{cc}{}{C}
\declinst{tt}{}{T}
\nextlevel
\mess{NonceC}{cc}{tt}
\nextlevel[2]
\mess{\{$pu_C$, $[byebye]_{pr_C}\}_{pu_T}$}{cc}{tt}
\end{msc}
\end{postscript}
\end{center}

\subsection{e}

\begin{center}
\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=4cm]
  \node[initial,state,accepting] (deact)      {$D$};
  \node[state]         (init) [right of=deact]  {$d$};


  \path[->] (deact) edge              node {issue} (init)
        (init) edge [bend left]  node {block} (deact);
\end{tikzpicture}
\end{center}

\end{document}

enter image description here

Related Question