0

The issue

I'm learning about including multiple files into a latex document to have a more organised flow, and right off the bat I've come across a situation where the include command fails where the input command succeeds. Shouldn't they both work for the same file?

Files

File structure

.
├── Book
│   └── book.tex
└── Chapters
    └── chapter1.tex

Main book file (book.tex)

\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}

\title{My Book}
\author{First Last}
\date{\today}

\begin{document}
\maketitle

\input{../Chapters/chapter1.tex}
% \include{../Chapters/chapter1.tex} fails

The end.

\end{document}

Example chapter file (chapter1.tex)

\chapter{First Chapter}

\lipsum[10]

Editor and details

I'm on Ubuntu 20.04.4 LTS using the Visual Studio Code editor with the LatTeX Workshop extension using TeX Live, pdflatex and the pdfTeX engine.

When I use include instead of input, I get the following errors:

I can't write on file `../Chapters/chapter1.aux'.
\@include ...mmediate \openout \@partaux "#1.aux"
_______________________________________________________
Emergency stop.
\@include ...mmediate \openout \@partaux "#1.aux"
_______________________________________________________
 ==> Fatal error occurred, no output PDF file produced!
Transcript written on book.log.
Latexmk: Examining 'book.log'
=== TeX engine is 'pdfTeX'
Latexmk: Errors, so I did not complete making targets
3
  • 1
    \include writes an aux-file and for security reason this will not work if the file is in a parent directory. (Not related but better leave out the .tex ending). Commented Mar 20, 2022 at 16:04
  • @UlrikeFischer I see, moving book.tex out of the Book directory did the trick, thanks! Also, why is it better to leave out the .tex ending? Commented Mar 20, 2022 at 16:09
  • 1
    in older system it wouldn't work, it was changed only around two years ago, and so I'm still in the habit. See tex.stackexchange.com/a/319509/2388 Commented Mar 20, 2022 at 16:17

0

You must log in to answer this question.

Browse other questions tagged .