4

I'm using the chapterbib package for multiple bibliographies. I put the following two lines in the preamble.

\usepackage[square,numbers,sectionbib]{natbib}
\usepackage{chapterbib}

Included chapter files with

\include{Chapter01}

and added the bibliography to the end of each chapter with

\bibliographystyle{plainnat}
\bibliography{Bibliography}

This works perfectly. But when I put each chapter in its own sub directory and use \input rather than \include like this

\input{../101Chapter01/101Chapter01}

it produces the global bibliographies for each chapter. Any help will be highly appreciated.

lockstep
  • 250,273
MYaseen208
  • 8,587
  • This is true. You have to use \include because it generates its own .aux file whereas \input does not. But what's the problem now? Why do you want to use \input instead of \include? – Thorsten Jan 22 '12 at 07:22
  • @Thorsten: Thanks for your comment. Actually I want to keep each chapter file in separate directory. – MYaseen208 Jan 22 '12 at 07:26
  • This is no problem. You can use it like this: \include{path/to/my/file}. – Thorsten Jan 22 '12 at 07:28
  • @Thorsten: Is this okay \include{D:/Path1 from/Path2 from/101Chapter01}? What about space in the path name? Thanks – MYaseen208 Jan 22 '12 at 07:43
  • I have never tried \include using spaces in paths. Maybe this works: \include{"my path with spaces"/file}. But I generally recommend you to avoid spaces in paths. – Thorsten Jan 22 '12 at 07:43
  • I have been trying to run the chapterbib package with child files in various subdirectories using \include and full paths suggested by Thornsten. However, I have been unsuccessful as I cannot create AUX files for the children by running BibTex on each child. chapterbib needs the AUX files to work. I've read that MikTeX security may be preventing related AUX files from being written in different directories (if I'm reading this answer: http://tex.stackexchange.com/questions/2209/how-can-i-include-the-file-somedir-file-tex-in-the-file-somedir-subdir-another/2214#2214 correctly). –  Jan 27 '12 at 02:20
  • @Thorsten Please convert your three comments to an answer. – lockstep Jan 29 '12 at 12:39

1 Answers1

2

(Converted my comments to an answer as @lockstep requested)

Main question

This behavior is true. You have to use \include because it generates its own .aux file whereas \input does not.

There is no need to use \input when you want to use a path to another directory. This is also possible with \include (e.g. \include{path/to/my/file}).

Referencing to the comments

The OP also asked another question in a comment. Because it's not part of the original question I will split this section from the main answer.

Referencing to your comment which contains another question about spaces in paths I can only make some guesses because I have never tried to do so:

Maybe you could use " to hold the filename that contains spaces (e.g. \include{"my path with spaces"/file} or maybe \include{"my path with spaces/file"}). As I'm not sure about this I searched for related questions on tex.sx and found a promising answer by @Stefan Kottwitz (How to make \include work with a quoted string path containing spaces?). There he suggests to use the \space command in those cases (e.g. \include{"my\space path\space with\space spaces/file"}).

But I generally recommend you to avoid spaces or special characters in paths because it may also cause problems if you're using your files on different operating systems.

Thorsten
  • 12,872