Sublime Forum

Strange build script issue witch latex

#1

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:

{ "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]This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
entering extended mode
(/home/wassuup/Desktop/test.txt
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, 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 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][/code]

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.

{ "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.

Thanks in advance for your help!

0 Likes

[bug] Build scripts don't work with unicode paths
#2

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

0 Likes

#3

Have you tried “selector”: “text.tex.latex” ?

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

gist.github.com/2852859

:smile:

0 Likes

#4

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.

0 Likes

#5

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:

Traceback (most recent call last): File "./sublime_plugin.py", line 325, in run_ File "./exec.py", line 124, in run UnicodeEncodeError: '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?

0 Likes

#6

It seems to be a bug, see those threads too:


0 Likes