Using TeXworks, I can put the following code at the very top of a TeX document:

% !TeX program = LuaLaTeX
% !TEX encoding = UTF-8

When TeXworks sees that, it will automatically use LuaLaTeX as compiler, and utf-8 encoding for this document, even if the program preferences are set to something else.

Alternatively, I can use various commands such as

\ifluatex{no problem}{stop, and inform the user}

My question: For the various TeX-specific editors (not general text editors), would the processing instructions for TeXworks also do the same thing? Or, is there some general way of ensuring the correct processing from the very start, without having to detect and generate an error later?

  • 1
    one of the answers in the linked question tex.stackexchange.com/questions/78101/… lists editors that understand those comments – David Carlisle Sep 21 '16 at 14:45
  • Excellent! That's what I needed to know. I could not find it via search, because I was looking for "processing" rather than "directives." It helps to know what something is called (should have known from XML). – user103221 Sep 21 '16 at 14:48
  • On that basis, I think this is a dupe – Joseph Wright Sep 21 '16 at 15:46
  • Kile doesn't read them, for example. – cfr Sep 21 '16 at 22:21
  • I think the key is that not very many editors can interpret these directives. Emacs (e.g.) has its own set of methods. Of course, if the files are all for your own benefit, then a lack of universality hardly matters. – jon Sep 22 '16 at 3:40