2

I have written a template for a personal diary. The main tex file \input a file called entries.tex, which will \input all the diary entries, which are in a subdirectory, as well as write the title of the entry and the date it is in (both of which it gets from the path and filename)

entries.tex is generated by a python script called entries.py, the output of this script looks like this:

\textbf{This is the title}  \hspace*{\fill}  \textbf{2018-11-16}\\
\input{entries/2018/11/16 - This is the title} \bigskip

\textbf{This is another entry}  \hspace*{\fill}  \textbf{2018-11-18}\\
\input{entries/2018/11/18 - This is another entry} \bigskip

And the main.tex file looks like this:

\documentclass{article}
\usepackage[margin=4cm,left=2cm,right=2cm]{geometry}

\title{\huge{}Personal Diary}
\author{\LARGE{}Author name}
\date{Last written \today}

\begin{document}

\maketitle
\newpage

\input{entries}

\end{document}

The directory tree looks like this:

Diary
├── entries
│   └── 2018
│       ├── 01
│       ├── 02
│       ├── 03
│       ├── 04
│       ├── 05
│       ├── 06
│       ├── 07
│       ├── 08
│       ├── 09
│       ├── 10
│       ├── 11
│       │   ├── 16 - This is the title.tex
│       │   └── 18 - This is another entry.tex
│       └── 12
├── entries.py
├── entries.tex
├── main.tex
└── makefile

However, when I try to compile main.tex, it seems to find entries.tex, but not the files that entries.tex includes. The output of it looks like this:

python3 entries.py
pdflatex main.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian)  (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./main.tex
LaTeX2e <2018-04-01> patch level 5
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
No file main.aux.
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./entries.tex

! LaTeX Error: File `entries/2018/11/16 - This is the title.tex' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: tex)

Enter file name: 

I'm sure that entries/2018/11/16 - This is the title.tex exists. Does anyone have any idea why LaTeX wouldn't be finding it?

I have made a github repo with all the code on for anyone who wants to try it out: https://github.com/ventlion/latexdiary

Vent
  • 35
  • you ask about \include but your example code does not use that command, it uses \input, but either way it is far simpler if you do not use spaces in file names. – David Carlisle Nov 18 '18 at 19:26
  • Whoops, my bad. I'll change that now. – Vent Nov 18 '18 at 19:28
  • 1
    if you really must use spaces then \input{"entries/2018/11/18 - This is another entry"} with double quotes but I would not use spaces. – David Carlisle Nov 18 '18 at 19:30
  • I have just tried it now, with underscores instead of spaces, and that has fixed the issue. Out of curiosity, what is wrong with using spaces and double quotes when using \input{}? – Vent Nov 18 '18 at 19:31
  • at the primitive tex syntax level the file input syntax is \input fooo with the filename terminated by a space.... but away from tex spaces in filenames are a pain, in a bash shell try ls 16 - This is the title.tex to see if it lists the filename... – David Carlisle Nov 18 '18 at 19:33
  • I see you're point. You'd have to escape the spaces. I may modify my script use underscores instead. Why is it that other LaTeX functions are okay with spaces (such as \textbf{this is some bold text}) – Vent Nov 18 '18 at 19:36
  • textbf doesn't have to access the filesystem using a syntax that works on linux, windows, ibm mainframes, atari, .... – David Carlisle Nov 18 '18 at 20:09

1 Answers1

3

From the LaTeX 2019-10-01 release onwards explicit " quoting is not necessary so

    \input{entries/2018/11/18 - This is another entry}

will work, but it is still true that it is better to avoid spaces in filenames,


The issue is spaces in filenames either use quotes as in

\input{"entries/2018/11/18 - This is another entry"}

or (usually better) avoid spaces in filenames.

The syntax of filenames is one of the few system dependent parts of TeX but this quote convention is supported by all web2c based distributions (so texlive and miktex in particular).

David Carlisle
  • 757,742