0

I have the following directory structure:

main.tex
content/
       intro.tex
       something.tex

I want to compile from any tex file. So, I have the following line (as suggested here) at the beginning of all the files within the content folder.

%!TEX root = ../main.tex

The content of the intro.tex is as follows:

%!TEX root = ../main.tex

\section{Introduction}
some text .........

I am using TexMaker, and when I try to build from intro.tex, I get the following error.

LOG FILE :
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex 2017.9.27) 30 JAN 2018 14:37
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**intro.tex
(./intro.tex
LaTeX2e <2016/02/01>
Babel <3.9q> and hyphenation patterns for 81 language(s) loaded.
! Undefined control sequence.
l.3 \section
{Introduction}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.

! Emergency stop.
<*> introduction.tex
*** (job aborted, no legal \end found)
Here is how much of TeX's memory you used:
11 strings out of 493029
236 string characters out of 6136234
53072 words of memory out of 5000000
3646 multiletter control sequences out of 15000+600000
3948 words of font info for 15 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
20i,2n,26p,731b,93s stack positions out of 5000i,500n,10000p,200000b,80000s
! ==> Fatal error occurred, no output PDF file produced!

Any help?

  • 1
    It's apparent that you're not typesetting main.tex. The %!TeX root key is for TeXworks, not Texmaker. Use the strategy suggested in https://tex.stackexchange.com/a/94415/4427 – egreg Jan 30 '18 at 12:47
  • Is there any solution for TexMaker? because I have done it in the past and it has worked, but I cant remember what extra thing I added – kingmakerking Jan 30 '18 at 12:48
  • Yes, there is: look at the suggestion above. – egreg Jan 30 '18 at 12:50
  • 1
    @kingmakerking Instead of texmaker, you could use the similar editor texstudio which knows magic comments like % !TeX root = ../main.tex – samcarter_is_at_topanswers.xyz Jan 30 '18 at 12:56

0 Answers0