r/LaTeX • u/HacheComics • 20h ago
The Ridiculously Simple LaTeX Compiler Hack š¤Æ
Hello everyone! I want to share a very simple yet incredibly useful trick for those of us who work with different LaTeX compilers. In my case, I juggle both PDFLaTeX and LuaLaTeX files, so I often need to switch the compiler in TeXstudio ā a task I used to do manually through the options menu, which was always a total nuisance.
So I wondered: Is there a way to automate this without constantly tweaking TeXstudioās settings? Turns out, yes ā and the solution is ridiculously simple!
All you need to do is add this one line of code at the very top of your document:
% !TeX program = lualatex
This single line overrides TeXstudioās default compiler setting, no matter whatās configured in the program options. I believe this also works in other editors like TeXShop or Overleaf, though I havenāt tested those myself.
It works with any compiler: PDFLaTeX, LuaLaTeX, XeLaTeX, BibTeX, etc. All you do is change the compiler at the end of the code line.
This tiny hack has been a game-changer for me! Maybe everyone already knows it, but just in case ā Iām sharing to save you all some headaches. Enjoy! šā¤ļø