2

I just started to write my thesis and i want to organize my document in Latex using the \input command, so for example, the main file main.tex is like this:

    \begin{document}
       \input{chapter1}
    \end{document}

and chapter1 have also nasted calls like this:

this chapter is devided into two main sections
    \input{firstsection}
    \input{secondsection}

besides, these sections have references to each others with \ref command and Latex could not resolve these references. I have read this here.

Is there a solution to solve this problem?

  • 2
    You have tried "2 The More Complex Method" with \include? – Heiko Oberdiek Jun 06 '14 at 15:30
  • 3
    One potential disadvantage of this method is that, unlike \input, each included file will automatically begin on a new page. – Massinissa Jun 06 '14 at 15:32
  • Might you be able to work with an editor/front end that supports code folding? That way, you don't need to keep track of lots of individual files and which one gets included or inputted by which. – Mico Jun 06 '14 at 15:43
  • 1
    @Massinissa: A chapter starts a new page anyway. Inside the included chapter file you can still use \input; \include cannot be nested. In opposite to \input, the references, table of contents, ... remain more or less intact, if an \include file is excluded from compiling, because the auxiliary data of the \include file are kept in a separate .aux file. – Heiko Oberdiek Jun 06 '14 at 15:49
  • 2
    the linked file was "last significantly updated" in 1993. thus it was intended for use with an earlier (now obsolete) version of latex. many things have improved since then, not least of which is the available documentation. – barbara beeton Jun 06 '14 at 16:11
  • cross references will work if the file is as you show, the comment in the linked file is that a reference to section 1 will fail if you have commented out section 1. – David Carlisle Jun 06 '14 at 16:13
  • This answer may help you: http://tex.stackexchange.com/questions/123058/subimport-and-includeonly/123096#123096. Cross references between files will work. – Ethan Bolker Jun 06 '14 at 16:42
  • References doesn't work? It is impossible. The LaTeX's \input expands to primitive \input and it realizes only one input stream independent of the file. Macros for references cannot distinguish what file is currently open and read. – wipet Jun 06 '14 at 17:05

1 Answers1

1

Since I was having the same problem as you a year ago, I can tell you ---after some intensive research--- that the best you can do is use \include for your chapters and \input for other codes (I'm specially thinking of TikZ here), sections, subsections, etc.

As stated in the comments, you are going to use a new page for every chapter, so that should be the end of the discussion with \include and chapters. Using \include here should be a plus, since it allows you to \includeonly the chapters you want to edit, leaving behind all the other ones that you are not currently working on. Now, since \includes can't be nested, you should consider using \inputs for your writing within each of these \include.

\input is specially useful for, say, Tikz pictures, or any code that should be easier to read the file's name instead of the whole thing; specially if once you have set it right, you don't want to mess it around anymore.

For starting writing, I strongly recommend one of the BEST books for thesis in LaTeX I have ever read: Using LaTeX to Write a PhD Thesis by Nicola Talbot, available here.

Mario S. E.
  • 18,609