## Strange build script issue witch latex

### Strange build script issue witch latex

Hi guys

I have encountered a strange problem on trying to set up a simple build script. I don't know if it's a bug, a fault of mine or a feature.

I wanted a simple script which just calls pdflatex on the currently editing file. So my script goes like this:

Code: Select all
{   "cmd": ["pdflatex", "$file"], "file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)", "selector": "source.tex"} It's saved under sublime-text-2/Packages/User/LaTeX.sublime-build It just doesn't work when editing .tex files (Pressing f7 or selecting build from the menu). Strangely enough, it works on non .tex-files. E.g. if i have opened a file 'test.txt' and I press f7, pdflatex gets called on it (and generates an error, obviously): Code: Select all This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)entering extended mode(/home/wassuup/Desktop/test.txtLaTeX2e <2009/09/24>Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, nohyphenation, ngerman, german, german-x-2009-06-19, ngerman-x-2009-06-19, loaded.! LaTeX Error: Missing \begin{document}.See the LaTeX manual or LaTeX Companion for explanation.Type H <return> for immediate help. ... l.1 T hat's a test.? ! Emergency stop. ... l.1 T hat's a test.! ==> Fatal error occurred, no output PDF file produced!Transcript written on test.log.[Finished] The only way to get it to work is to replace '$file' in the build file with the hardcoded name of the file I'm editing, E.g.
Code: Select all
{   "cmd": ["pdflatex", "serie10.tex"],   "file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)",   "selector": "source.tex"}

Naturally, this is not usable at all because I have to change it in the build script every time I edit another file. If build autodetect is on or off (I select LaTeX from the list manually then) doesn't matter.

wassuup

Posts: 5
Joined: Thu May 24, 2012 7:45 pm

### Re: Strange build script issue witch latex

No one has a clue? It'd be really nice to know how to solve it, it's a really annoying thing...
wassuup

Posts: 5
Joined: Thu May 24, 2012 7:45 pm

### Re: Strange build script issue witch latex

Have you tried "selector": "text.tex.latex" ?

I made a Gist recently about some Bibtex compilation in Sublime Text 2.

https://gist.github.com/2852859

arthuralvim

Posts: 2
Joined: Fri Jun 01, 2012 11:57 pm

### Re: Strange build script issue witch latex

For the build systems to work automagically, you need to set it to "Automatic" (Tools > Build System > Automatic) and then use the correct selector in the various individual build systems. As @arthuralvim pointed out, the scope for latex files is "text.tex.latex". So you need to change the selector in your build system for LaTeX to this scope.

You can find out what the scope is for a syntax by opening an appropriate file (e.g., *.tex), hitting Ctrl+Shift+Alt+P and looking in the status bar. You can also inspect the appropriate tmLanguage file. E.g., Packages > LaTeX > LaTeX.tmLanguage, all the way at the bottom of the file.
quodlibet

Posts: 574
Joined: Sat Jun 18, 2011 5:53 pm

### Re: Strange build script issue witch latex

Thanks for the information on the scope, i've changed it to 'text.tex.latex' now and the build script gets called corretly. However, id doesn't do anything and prints out the following error on the sublime text console:

Code: Select all
Traceback (most recent call last):  File "./sublime_plugin.py", line 325, in run_  File "./exec.py", line 124, in runUnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 75: ordinal not in range(128)

This is a totally different error. The path of the .tex file im editing contains an 'ä' (Umlaut a, unicode 0xE4), and apparently sublime doesn't handle unicode args correctly when calling plugins/build scripts. So I guess this should be considered a bug?
wassuup

Posts: 5
Joined: Thu May 24, 2012 7:45 pm

### Re: Strange build script issue witch latex

It seems to be a bug, see those threads too:
viewtopic.php?f=3&t=7414
viewtopic.php?f=3&t=4465&p=38634#p38634
Huge

Posts: 3
Joined: Fri Oct 19, 2012 9:55 am