3

QUESTION: I would like to know what are (or where I may find) a complete set of naming conventions for documents to be later referenced by pdfpages.

That is, I would ensure LaTeX documents, such as

\documentclass{article}
\usepackage{pdfpages}

\begin{document} \includepdf[pages={1,10-20,30}]{<pdf-file>} \end{document}

will always work---for I do not always think about the possible future use pdfpages when I am working on the underlying document.

I have checked the Pdfpages documentation on CTAN and could not find what I am looking for; nor, have I come across a comprehensive list upon checking various posts related to pdfpages.

For example, How to use tilde or space in includepdf filename? posts a question with references to using tilde or spaces. This post File names with spaces stopped working in \includepdf and \includegraphics in TeX Live 2019 if compiled with XeLaTeX specifies a problem with spaces when using XeLateX. And this post How to use pdfpages with files with utf8 chars in the name? complains about an error results from using utf8 characters.

Incidentally, I know, for example, that underscores are permitted. It also seems that names that contain spaces are sometimes OK, as I recall that it is not always that I have to rename and recompile an original document when trying to print a range of pages from it with pdfpages.

Finally, if I was acquainted with all (of most) of the naming conventions, then I could adopt them in all cases involving the naming of files and thus avoid the problem of having the LaTeX code abend when invoking pdfpages and an ill-named file.

I am mostly interested with naming conventions when using Pdflatex.

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36
  • what makes you think there are any file names that do not work? – David Carlisle Aug 28 '21 at 21:10
  • @David Carlisle I've encountered that problem many times; most recently, I had a file whose name contained spaces---finally, after renaming the file as one continuous word with underscores, I was able to display the desired pages. But I have encountered in the past, naming scenarios where spaces in the name are allowed. Hence, some of the reasons for the question. – DDS Aug 28 '21 at 21:58
  • in older latex releases you may have to quote spaces with " but in all cases you should be able to access any file on the filesystem as far as I know, If you provided an example of a filename where pdfpages gives an error someone could maybe answer but as it is I don't see how the question can be answered. – David Carlisle Aug 28 '21 at 22:24
  • 1
    web2c tex can not reference files that have a " in the filename. So you cannot use such a file with tex at all for \input or \includegraphics or \includepdf I don't think there is any other constraint on filenames. – David Carlisle Aug 28 '21 at 22:38
  • @David Carlisle Thank you for your comments. I have updated the question with some posts from this site expressing problems with file names and pdfpages. – DDS Aug 28 '21 at 22:53
  • those posts are not relevant eg the last one is about xetex in 2014. the base latex release didn't support xetex until 2015. spaces and utf8 in filenames support in latex is from 2019. – David Carlisle Aug 29 '21 at 09:17

1 Answers1

5

Which file names "work" doesn't depend only on a package or LaTeX but also on your operating system (Windows, Linux,...), its age (Windows 7 or 10, the engine you are using (pdflatex, lualatex, ...), the tex system (texlive, miktex) and its age (texlive 2014 or 2021).

Safe files names

You are on the completely safe side if you use only a-Z, digits, hyphen, underscore and one period before the extension.

Spaces

Spaces works normally in a current TeX system. In older systems you should avoid them. But they rely on correct quoting, and in more complicated workflows involving scripts or calls to other tools quoting can easily go wrong. I never use spaces in file names.

Umlauts and other non-ascii letters

They work (and they should work, in todays world file names shouldn't be restricted to english but support other languages like greek or chinese too) but require that all your files are utf8-encoded and that you have a current LaTeX, OS and engines. On windows with lualatex for example this is for texlive only the case since april 2020 (so final texlive 2020) and windows 10.

Periods

In a current system including PDF's with more than one period should work. In older systems avoid them.

File name separators and wildcards

Avoid things like : / \ *~ and similar that are relevant in the file system of your OS and if you share your files also in other OS.

The list of chars here can be quite long, you can find e.g. lists like @ $ % & \ / : * ? " ' < > | ~ ` # ^ + = { } [ ] ; !. They don't need to be still true, the requirements of the OS changed here over time. Windows allows a lot of curious names.

Ulrike Fischer
  • 327,261