0

I want to provide some structure for my thesis source files. I decided to use nested directories. Every directory contains main.tex index file to be imported by a file in the parent directory.

From Path to External Files in Nested \input I learned about import package, however it is not working for me.

For the simplest case

/
+- main.tex: |\documentclass{report}
|            |\usepackage{import}
|            |\begin{document}
|            |main
|            |
|            |\subimport{a}{main.tex}
|            |\end{document}
+- a/
    +- main.tex: |a main

I expect to have result like:

main

a main

Instead, I get the following error during compilation:

$ pdflatex main
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)
 restricted \write18 enabled.
entering extended mode
(./main.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 5 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/import/import.sty) (./main.aux)
(./main.tex

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.1 \documentclass
                  {report}

\subimport{a}{main} nor \subimport{a/}{main} neither works.

How can I tell the import package not to look for import files in the root directory? Also I wonder, if the issue won't occur in subdirectories too (at the moment I was unable to cause it).

abukaj
  • 147

0 Answers0