On my Windows 8.1 with MikTeK installed, the following C# code successfully generates a PDF file with Math expressions except for some Unicode codes such as plusminus sign:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "pdflatex.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = Test.tex;

For example, in my tex file I've two math expressions one \sqrt{2} with square root symbol and one a\unicode{177}b with plusminus sign. The above code correctly displays square root sign in the resulting PDF file but the expression with plusminus sign displays as a<177>b. The error shown in the corresponding Test.log file generated by MikTeK is shown below. The error is UC: bad: 177. The same tex file correctly displays math expressions when directly using the DOS command in Windows as pdflatex Test.tex:

LaTeX Font Info:    Try loading font information for U+msa on input line 19.
("C:\Program Files (x86)\MikTeX\tex\latex\amsfonts\umsa.fd"
File: umsa.fd 2013/01/14 v3.01 AMS symbols A
LaTeX Font Info:    Try loading font information for U+msb on input line 19.

("C:\Program Files (x86)\MikTeX\tex\latex\amsfonts\umsb.fd"
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
UC: bad: 177

UPDATE I'm using a tex file generated via David's stylesheet. The entire content of the file is:






When using pdflatex inside C# code (shown above) I get the following pdf: enter image description here. But the same tex file correctly generates the pdf shown below when using the command pdflatex Test.tex in the DOS window or when using TeXworks editor: enter image description here

  • Is there a reason you're not just using a \pm b? – Arun Debray Dec 7 '15 at 22:58
  • @ArunDebray I'm using David Carlisle's stylesheet that is using \unicode{...} for symbols. – nam Dec 7 '15 at 23:02
  • 1
    the error message is from latex, so all the description and C# can not be relevant, please just post a small latex file that gives that error. – David Carlisle Dec 7 '15 at 23:11
  • @DavidCarlisle Per your request I've posted the latex file along with an Update section in my original post. – nam Dec 8 '15 at 4:14

You did not say but this is pmml-new.sty which sets up a mechanism to declare behaviour for unicode characters but leaves most undefined. You need to define 177 as \pm so


should define this character.

  • I've added an Update section in my original post. \@namedef{uc177}{\pm} is included in the pmm-new.sty and the tex file correctly generates the PDF with math expression in question when using DOS command or Texworks editor. – nam Dec 8 '15 at 4:12
  • 1
    @nam check the paths in the log file, presumably you are picking up different versions of the style without that definition. – David Carlisle Dec 8 '15 at 7:46
  • Your assumption is correct. It's working now. You may want to add your above comment to your Answer. I had included \@namedef{uc177}{\pm} in the file pmml-new.sty that is the part of .NET project but that change was not reflecting in the Output directory of the project because the Copy to Output Directory property of the file was not set to Copy if newer hence the project build was still using the older version during the build. Ref: See the image – nam Dec 8 '15 at 19:17
  • For benefit of other readers of this post: Please note that the response from David Carlisle and his comments above - regarding what I may be missing - I had resolved the issue. I was just revisiting the post for another related task of mine, and noticed that I had not marked David's response as an Answer. – nam Apr 30 '19 at 17:13

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.