I am writing my thesis using a multiple.tex file. I have a main file that calls different subtex files. The main file works properly while compiling. However, when I am trying to compile the subfile, it shows the following error :

(chapter1.tex LaTeX2e <2023-11-01> patch level 1 L3 programming layer <2024-03-14> ! Undefined control sequence. l.2 \chapter {Introduction} ?

My subfile starts with the following code:

\graphicspath{ {Figures/Chapter1/} }

Can I directly compile my subfile to open the main PDF? Right now, I have to again revert to the main file to compile the full PDF.

I am using TeXworks with the MiKTeX console on macOS.

  • 1
    Welcome to TeX.SE!
    – Mensch
    Commented May 6 at 6:36
  • What document class are you using? Are you perhaps trying to compile the chapter files directly without a top-level file containing the class?
    – Joseph Wright
    Commented May 6 at 7:00
  • @JosephWright I am using the document class "report." I am using the 'include" command in the main file. I am starting my subfile with the command \chapter{} . I have edited my question a bit with the correct code for the subfile Commented May 6 at 7:50
  • Your subfile is a chunk of a document, you cannot compile it "as is". If you want to see previews of the child files, see here.
    – Fran
    Commented May 6 at 8:00
  • @Fran, I borrowed the entire Tex file from a friend who wrote his thesis using the same subfile. The only difference is that he is running the tex file on Tex Studio on macOS. The same code works perfectly fine on his computer with Tex Studio. And one can compile the subfiles also. I am using the same Tex file just on TeXworks. I think the problem is associated with the different Tex software. I think the code is correct. Commented May 6 at 8:34


Browse other questions tagged .