I want to compile my file named code correcteur.tex using the terminal, I entered pdflatex code correcteur.tex but it keeps telling me that the file cannot be found. I am sure I navigated to the right directory, and I was able to compile another tex. file in the same directory. However, when I typed dir code correcteur.tex*, nothing happened. I guess it's because there's a space in the file name, can someone please tell me why?

  • 4
    It’s looking for the file code.tex. Put double quotes around the full file name. It’s good practice to not use spaces in file names. May 10, 2020 at 14:31
  • 3
    It's recommended to avoid spaces, especially in programs. There are many a software that go around this issue, like a "Click to open files" thing where spaces are not a problem. However, it's still good practice to replace spaces with underscores.
    – Someone
    May 10, 2020 at 14:54
  • The presence of spaces in file names is discussed in this question from a somewhat different perspective: Spaces in files names in \input or \includegraphics May 10, 2020 at 19:34

1 Answer 1


I guess it's because there's a space in the file name

Exactly. I'm not sure on which operating system you are, but in all operating system the space is used as a separator between program arguments. pdflatex therefore sees two arguments, code and correcteur.tex. The first argument which doesn't start with a hyphen is interpreted as the name of the source file (including a .tex extension if not specified), and it'll probably try to interpret correcteur.tex as a TeX command.

Depending on your operating system, you can either use double quotes around the filename (as @HerbSchulz mentioned in the comments):

pdflatex "code correcteur.tex"

or escape the space:

pdflatex code\ correcteur.tex

In both cases the operating system will correctly interpret your intention of wanting to specify a single argument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.