0

I 'm writing a book and I 'm trying to incorporate the chapters that are in other tex files.

I have these chapters:

ch1.tex

\chapter{1st chapter}

\begin{examp}
example1 example1
\end{examp}

text1 text1

ch2.tex

\chapter{2nd chapter}

\begin{examp}
example2 example2
\end{examp}

text2 text2

ch3.tex

\chapter{3rd chapter}

\begin{examp}
example3 example3
\end{examp}

text3 text3

And this is the main file:

main.tex

\documentclass{book}

\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{examp}{Example}[section]

\begin{document}

main text

\include{ch1.tex}

\include{ch2.tex}

\include{ch3.tex}

\end{document}

The problem is that nothing appears when I compile or build the main.tex. I also compiled and build (just for experimentation, I don't know if it was a good idea) the ch1.tex, ch2.tex and ch3.tex, but nothing yet...

What am I doing wrong?

Thanks in advanced!

  • @CarLaTeX , yes they are in the same folder. – Kώστας Κούδας Mar 15 at 8:59
  • @CarLaTeX thank's for the idea! There was no error indication, but the log-file (here pastebin.com/6mqjBGca) was writing No file ch1.tex.tex., so I realize that the problem was with \include{ch1.tex}, so I change it to \include{ch1} and the problem solved! – Kώστας Κούδας Mar 15 at 9:07
  • 2
    Exactly. You'll see this if you look in the log. It says No file ch1.tex.tex. \include always assumes its argument is a filename without extension – daleif Mar 15 at 9:08
  • Related/duplicate: tex.stackexchange.com/questions/319506/… – egreg Mar 15 at 12:57
5
\include{ch1.tex}

should be written af

\include{ch1}

as \include always assumes its argument is a file name without extension.

This is also evident from the log file

No file ch1.tex.tex.
No file ch2.tex.tex.
No file ch3.tex.tex.

Note that \include does not throw an error if it cannot find a file.

  • This is the correct answer – egreg Mar 15 at 11:53
  • I accepted both answers, because both solved my problem. – Kώστας Κούδας Mar 15 at 20:15
1

Try to put this in your main:

\input{ch1.tex}

instead of \include{}

  • @Rune thank's a lot!!! Problem solved! Do you know what was the problem with \include{}? – Kώστας Κούδας Mar 15 at 9:02
  • @KώσταςΚούδας this step should not be necessary, are you 100% sure you are testing with the code you provide above. For example please explain what you mean by but nothing yet... – daleif Mar 15 at 9:05
  • A final question: What do you recommend as a solution? \input{ch1.tex} or \include{ch1}? – Kώστας Κούδας Mar 15 at 9:09
  • @KώσταςΚούδας, I encountered the problem some time ago, but I have not tried to figure out why it solves it. – Rune Mar 15 at 9:11
  • Depends on your needs. \include has the advantage that it can be used with \includeonly and references to files not listed in `\includonly will still work. – daleif Mar 15 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.