Skip to content

Instantly share code, notes, and snippets.

@zhuth
Created November 19, 2012 02:10
Show Gist options
  • Save zhuth/4108587 to your computer and use it in GitHub Desktop.
Save zhuth/4108587 to your computer and use it in GitHub Desktop.
Run pdflatex, then bibtex, then pdflatex twice to get correct pdf output. Used for texworks. CsSC script.
var pdflatex = @"D:\Programs\CTEX\MiKTeX\miktex\bin\pdflatex.exe";
var bibtex = @"D:\Programs\CTEX\MiKTeX\miktex\bin\bibtex.exe";
string[] argpdf = new string[args.Length - 1];
for (int i = 0; i < args.Length - 1; ++i) argpdf[i] = args[i];
start(pdflatex, argpdf);
start(bibtex, new string[]{args[args.Length - 1]});
start(pdflatex, argpdf);
start(pdflatex, argpdf);
#function
static void start(string cmd, string[] args) {
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = cmd;
startInfo.UseShellExecute = false; //not sure if this is absolutely required
//startInfo.RedirectStandardOuput = true;
string argsstr = "";
foreach(string arg in args) argsstr += " " + arg;
argsstr = argsstr.Substring(1);
startInfo.Arguments = argsstr;
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
#endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment