When I'm working on a LaTeX document and compiling with pdflatex, I frequently have compile errors. To get out of pdflatex when running it from the command line, I use the exit command to end the pdflatex process:

$ pdflatex kevin.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex)
! Undefined control sequence.
l.276 ...2' \ldots c_j'\}$, $w \notin \{q_1 \lodts
    q_i\}$. $S \cap T$ is alw...
? exit

Once I use the exit command, pdflatex immediately brings up my tex document in vim. Is there any way to prevent this? I don't want pdflatex to open any text editor whatsoever when I exit it. I want the command line terminal to return to the shell and wait for more input. (I'm using a different text editor for editing, and having to close vim every time it opens after an error just wastes my time and is getting annoying.)

  • 1
    Why do you go to the effort of typing exit rather than just Ctrl-D to end the run?
    – Joseph Wright
    Nov 13, 2014 at 8:06
  • I can just do that? =P
    – Kevin
    Nov 13, 2014 at 8:49
  • When I first started using pdflatex, I mistakenly used Ctrl-Z to end runs, meaning that I had many instances of pdflatex running uselessly in the background. My first thought when I realized my mistake was to try to find a way to close pdflatex with a command, which is why I'm now in the habit of using exit. If using Ctrl-D is the typical way to close pdflatex, I will accept that as the answer.
    – Kevin
    Nov 13, 2014 at 8:51

1 Answer 1


When TeX, in interactive mode, shows the ? prompt after an error, you have a few choices, but you should keep in mind that the first character you type determines the subsequent behavior:

  • return means “ignore the error and proceed”
  • s means “run showing future error messages without stopping except for requesting user input”
  • r means “run showing future error messages, stopping if user input is required”
  • q means “run quietly” (without showing anything)
  • i means “insert something in the input stream”
  • x means “stop here”
  • e means “stop here and open the editor on the file at the current line number”
  • a digit

In case you type i, TeX will insert the tokens you type after it until hitting return (which will count as a space); if you immediately hit return, you'll be prompted for the tokens to insert.

In case you type a digit, TeX will determine a <number> based on its rules from the subsequent characters you type. Hitting return will ignore <number> tokens from the input stream and TeX will stop again showing the ignored tokens, waiting for further input. Except in cases of i and of a digit, extra characters will be ignored.

So, typing exit is exactly the same as typing e, which has the behavior you are experiencing.

The correct way for exiting is typing x.

Note that lowercase or uppercase is irrelevant, so S R Q I X E have the same effect as s r q i x e.

On some implementations, hitting control-D will trigger the “emergency stop”, basically similar to typing x. On some implementations, hitting e is the same as typing x, but not in TeX Live, which will use the current value of the environment variable TEXEDIT for opening the file (if set in the environment). The value can be also set in the top level texmf.cnf file. For instance, my top level texmf.cnf file is

% (Public domain.)
% This texmf.cnf file should contain only your personal changes from the
% original texmf.cnf (for example, as chosen in the installer).
% That is, if you need to make changes to texmf.cnf, put your custom
% settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
% the distributed file (which is .../texlive/YYYY/texmf-dist/web2c/texmf.cnf).
% And include *only* your changed values, not a copy of the whole thing!
TEXMFHOME = ~/Library/texmf
TEXMFVAR = ~/Library/texlive/2014/texmf-var
TEXMFCONFIG = ~/Library/texlive/2014/texmf-config
TEXEDIT = nano +%d '%s'

so typing e will open the file in nano.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .