Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[LaTeX] Spaces in included files

172 views
Skip to first unread message

Maciej Piechotka

unread,
Feb 24, 2008, 5:00:03 PM2/24/08
to
I am looking for a package, which allow me to include/import files with spaces
in them. Something like grffile but for \include or \import.
If it give any help I use texlive 2007 and pdflatex.

Regards
--
I've probably left my head... somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)

vvvv

unread,
Feb 25, 2008, 2:01:59 AM2/25/08
to
I don't know what you mean about the spaces. Are you saying that the
path name or file name has embedded spaces? That would be something
like:

\input{/Examples/junk.tex}
\input{/Examples/junk space.tex}

Perhaps you are not using the braces as shown above?? If you are
talking about importing files that contain spaces in the file, then I
don't know what you are asking because I can't imagine what the
problem is.

Maciej Piechotka

unread,
Feb 25, 2008, 2:20:42 AM2/25/08
to
vvvv <vne...@gmail.com> writes:

> I don't know what you mean about the spaces. Are you saying that the
> path name or file name has embedded spaces? That would be something
> like:
>
> \input{/Examples/junk.tex}
> \input{/Examples/junk space.tex}
>

Yes. But see below.

> Perhaps you are not using the braces as shown above?? If you are
> talking about importing files that contain spaces in the file, then I
> don't know what you are asking because I can't imagine what the
> problem is.

% cat junk\ file.tex
\section{Junk}
% cat test.tex
\documentclass{article}
\begin{document}
\input{junk file.tex} % I've tried all combinations of rel/abs. paths
\end{document}
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
%&-line parsing enabled.
entering extended mode
(./test.tex
LaTeX2e <2005/12/01>
Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, polish, ukenglish, loaded.
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size10.clo)) (./test.aux)

! LaTeX Error: File `junk file.tex' not found.

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

Maciej Piechotka

unread,
Feb 25, 2008, 2:22:52 AM2/25/08
to
vvvv <vne...@gmail.com> writes:

I have tried and it works for include but not for input. Why?

Maciej Piechotka

unread,
Feb 25, 2008, 2:31:54 AM2/25/08
to
Maciej Piechotka <uzytk...@gmail.com> writes:

> vvvv <vne...@gmail.com> writes:
>
>> I don't know what you mean about the spaces. Are you saying that the
>> path name or file name has embedded spaces? That would be something
>> like:
>>
>> \input{/Examples/junk.tex}
>> \input{/Examples/junk space.tex}
>>
>> Perhaps you are not using the braces as shown above?? If you are
>> talking about importing files that contain spaces in the file, then I
>> don't know what you are asking because I can't imagine what the
>> problem is.
>
> I have tried and it works for include but not for input. Why?
>

Even stranger: from given files with s/input/include/g; the file contains only
"file.tex".

Ulrike Fischer

unread,
Feb 25, 2008, 3:44:58 AM2/25/08
to
Am Sun, 24 Feb 2008 23:00:03 +0100 schrieb Maciej Piechotka:

> I am looking for a package, which allow me to include/import files with spaces
> in them. Something like grffile but for \include or \import.
> If it give any help I use texlive 2007 and pdflatex.
>

On windows (miktex) I can use \input{"test space"}.


--
Ulrike Fischer

vvvv

unread,
Feb 25, 2008, 9:46:52 AM2/25/08
to

> Even stranger: from given files with s/input/include/g; the file contains only
> "file.tex".
>

I'm not sure what you are saying here. I'm assuming the s/input/
include/g is a "change" command, but which "file contains only
'file.tex' ?"

You said that you are using texlive from 2007 (me too). ***Are you
using Linux, Mac, Windows*** ???

Try the quotes like in the example above. Another thing to try would
be to ****change your directory so that you run pdflatex from the
directory where all the .tex files are*** and try this to test what
works (the input file is called "junk space.tex"):

\documentclass{article}
\begin{document}
regular:
\input{regularfilename.tex}

braces:
\input{junk space.tex}

no extension:
\input{junk space}

quotes and braces:
\input{"junk space"}

slash before the space:
\input{junk\ space.tex}


slash before the space, and no extension
\input{junk\ space}


quotes and slash before the space
\input{"junk\ space.tex"}

quotes and slash before the space, no extension
\input{"junk\ space"}
\end{document}

Maciej Piechotka

unread,
Feb 25, 2008, 12:36:10 PM2/25/08
to
vvvv <vne...@gmail.com> writes:

>> Even stranger: from given files with s/input/include/g; the file contains only
>> "file.tex".
>>
>
> I'm not sure what you are saying here. I'm assuming the s/input/
> include/g is a "change" command, but which "file contains only
> 'file.tex' ?"
>

It's a regex but what I meant was that I replaced the input command with
include command.

> You said that you are using texlive from 2007 (me too). ***Are you
> using Linux, Mac, Windows*** ???
>

GNU/Linux

> Try the quotes like in the example above. Another thing to try would
> be to ****change your directory so that you run pdflatex from the
> directory where all the .tex files are*** and try this to test what
> works (the input file is called "junk space.tex"):
>
> \documentclass{article}
> \begin{document}
> regular:
> \input{regularfilename.tex}
>
> braces:
> \input{junk space.tex}
>
> no extension:
> \input{junk space}
>
> quotes and braces:
> \input{"junk space"}
>
> slash before the space:
> \input{junk\ space.tex}
>
>
> slash before the space, and no extension
> \input{junk\ space}
>
>
> quotes and slash before the space
> \input{"junk\ space.tex"}
>
> quotes and slash before the space, no extension
> \input{"junk\ space"}
> \end{document}

% ls -l
total 12
-rw-r--r-- 1 uzytkownik uzytkownik 21 2008-02-25 18:29 junk space.tex
-rw-r--r-- 1 uzytkownik uzytkownik 26 2008-02-25 18:28 regularfilename.tex
-rw-r--r-- 1 uzytkownik uzytkownik 443 2008-02-25 18:30 test.tex
% pdflatex test.tex


This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
%&-line parsing enabled.
entering extended mode
(./test.tex
LaTeX2e <2005/12/01>
Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, polish, ukenglish, loaded.
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size10.clo)) (./test.aux)

(./regularfilename.tex)

! LaTeX Error: File `junk space.tex' not found.

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

Enter file name:

! LaTeX Error: File `junk space.tex' not found.

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

Enter file name:
(./junk space.tex)

! LaTeX Error: File `junk\ space.tex' not found.

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

Enter file name:

! LaTeX Error: File `junk\ space.tex' not found.

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

Enter file name:

! LaTeX Error: File `"junk\ space.tex"' not found.

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

Enter file name:

! LaTeX Error: File `"junk\ space".tex' not found.

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

Enter file name:
[1{//var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./test.aux) )</usr/sha
re/texmf-dist/fonts/type1/bluesky/cm/cmbx12.pfb></usr/share/texmf-dist/fonts/ty
pe1/bluesky/cm/cmr10.pfb>
Output written on test.pdf (1 page, 13758 bytes).
Transcript written on test.log.

Result: It need to be in quotes(check in the pdf).

Thanks

Rolf Niepraschk

unread,
Feb 25, 2008, 1:21:56 PM2/25/08
to
Maciej Piechotka schrieb:

> I am looking for a package, which allow me to include/import files with spaces
> in them. Something like grffile but for \include or \import.
> If it give any help I use texlive 2007 and pdflatex.
>
> Regards

Try the following:

\usepackage{grffile}
...
\makeatletter
\AtBeginDocument{%
\@ifpackageloaded{grffile}{%
\let\IfFileExists=\grffile@IfFileExists
}{}%
}
\makeatother

...

...Rolf

Dan

unread,
Feb 25, 2008, 6:42:54 PM2/25/08
to
On Feb 25, 1:31 am, Maciej Piechotka <uzytkown...@gmail.com> wrote:
> Maciej Piechotka <uzytkown...@gmail.com> writes:

> > vvvv <vnes...@gmail.com> writes:
>
> >> I don't know what you mean about the spaces. Are you saying that the
> >> path name or file name has embedded spaces? That would be something
> >> like:
>
> >> \input{/Examples/junk.tex}
> >> \input{/Examples/junk space.tex}
>
> >> Perhaps you are not using the braces as shown above?? If you are
> >> talking about importing files that contain spaces in the file, then I
> >> don't know what you are asking because I can't imagine what the
> >> problem is.
>
> > I have tried and it works for include but not for input. Why?
>
> Even stranger: from given files with s/input/include/g; the file contains only
> "file.tex".

Typically, \input{junk space.tex} will ultimately perform

\@@input junk space.tex

where \@@input is TeX's input primitive.
TeX's input primitive uses a space as a file name delimiter,
so file.tex will be input and "space.tex" will be printed.

The *very best* solution: don't use spaces in file names.
This is also the second and third best solution. In fact,
there are no other good solutions.


Dan

Robin Fairbairns

unread,
Mar 3, 2008, 2:43:03 AM3/3/08
to
Dan <luec...@uark.edu> writes:
>The *very best* solution: don't use spaces in file names.
>This is also the second and third best solution.

it is also a council of (seemingly impossible) perfection.

we can of course discount the m$-loony solution of saving documents
with their first sentence as title, by default. however, since before
m$ had their act together, file names with spaces have been with us on
macs, and it's a rare student coming up through our computer science
courses for whom the idea of "verboten space" is a curious anachronism.

>In fact there are no other good solutions.

apart from "file name", which (i believe) works with all current free
distributions. (dunno about commercial ones.)
--
Robin Fairbairns, Cambridge

Dan

unread,
Mar 3, 2008, 5:32:32 PM3/3/08
to
On Mar 3, 1:43 am, r...@cl.cam.ac.uk (Robin Fairbairns) wrote:

Until you try it with \include, which complains:
No file "file.tex.
(with exactly that unbalanced quote) in
pdfTeX 3.141592-1.50.0-alpha-20080125-2.2 (Web2C 7.5.6)
(format=latex 2008.2.5) 3 MAR 2008 16:19
(from w32TeX).

No sir, I don't like it.


Dan

Robin Fairbairns

unread,
Mar 5, 2008, 2:44:35 PM3/5/08
to
Dan <luec...@uark.edu> writes:
>> apart from "file name", which (i believe) works with all current free
>> distributions. (dunno about commercial ones.)
>
>Until you try it with \include, which complains:
> No file "file.tex.
>(with exactly that unbalanced quote) in
> pdfTeX 3.141592-1.50.0-alpha-20080125-2.2 (Web2C 7.5.6)
> (format=latex 2008.2.5) 3 MAR 2008 16:19
>(from w32TeX).
>
>No sir, I don't like it.

i didn't notice your latex bug report. did you send one, or shall i?

i can see why it happens -- the latex code assumes there's no space in
the file name. i don't really understand what that gains, but it's
probably something to do with parsing file names for aux files.

should really be corrected; i'll see what i can do before the next
release.
--
Robin Fairbairns, Cambridge

Dan

unread,
Mar 6, 2008, 1:39:34 PM3/6/08
to
On Mar 5, 1:44 pm, r...@cl.cam.ac.uk (Robin Fairbairns) wrote:

> Dan <lueck...@uark.edu> writes:
> >> apart from "file name", which (i believe) works with all current free
> >> distributions. (dunno about commercial ones.)
>
> >Until you try it with \include, which complains:
> > No file "file.tex.
> >(with exactly that unbalanced quote) in
> > pdfTeX 3.141592-1.50.0-alpha-20080125-2.2 (Web2C 7.5.6)
> > (format=latex 2008.2.5) 3 MAR 2008 16:19
> >(from w32TeX).
>
> >No sir, I don't like it.
>
> i didn't notice your latex bug report. did you send one, or shall i?

I assumed it was working as intended. I don't know the
exact specification of filenames for different systems, so
I am unsure if it should be changed and if so, how..
I also don't feel any need to bother changing things, so
you go ahead and decide if a bug report is needed.

I found this work-around, which was tested only on my alpha
pdftex engine from w32TeX mentioned above):
\include{{"file name"}}

The extra braces prevent the space in "file name" from being a
delimiter for \@include's parameter, but are stripped by the
parameter processing itself. The quotes allow the engine's
primitive \input to get the file. The .aux gets correctly reported
in the .log as
\openout2 = `"file name.aux"'
as long as there are no extraneous spaces inside the inner
braces

>
> i can see why it happens -- the latex code assumes there's no space in
> the file name. i don't really understand what that gains, but it's
> probably something to do with parsing file names for aux files.

Probably it was intended to safely handle extra space in the argument,
to prevent \include{ file } from producing "file .aux".

When working at a command line, spaces in file names are nothing
but nuisances. Since there seem no cases where they must
be used, I always advise they not be used.


Dan

Robin Fairbairns

unread,
Mar 7, 2008, 4:18:06 AM3/7/08
to
Dan <luec...@uark.edu> writes:
>On Mar 5, 1:44 pm, r...@cl.cam.ac.uk (Robin Fairbairns) wrote:
>> Dan <lueck...@uark.edu> writes:
>> >> apart from "file name", which (i believe) works with all current free
>> >> distributions. (dunno about commercial ones.)
>>
>> >Until you try it with \include, which complains:
>
>> i didn't notice your latex bug report. did you send one, or shall i?
>
>I assumed it was working as intended.

no doubt, but with the "intention" changing, with support from the
distributions, latex itself ought to support it. imo.

>I don't know the
>exact specification of filenames for different systems, so
>I am unsure if it should be changed and if so, how..

for now, surely, making latex support the same things as the
underlying tex system, would be good enough.

>I also don't feel any need to bother changing things, so
>you go ahead and decide if a bug report is needed.
>
>I found this work-around, which was tested only on my alpha
>pdftex engine from w32TeX mentioned above):
> \include{{"file name"}}
>
>The extra braces prevent the space in "file name" from being a
>delimiter for \@include's parameter, but are stripped by the
>parameter processing itself. The quotes allow the engine's
>primitive \input to get the file. The .aux gets correctly reported
>in the .log as
> \openout2 = `"file name.aux"'
>as long as there are no extraneous spaces inside the inner
>braces

that

>> i can see why it happens -- the latex code assumes there's no space in
>> the file name. i don't really understand what that gains, but it's
>> probably something to do with parsing file names for aux files.
>
>Probably it was intended to safely handle extra space in the argument,
>to prevent \include{ file } from producing "file .aux".

indeed. but there are so many other placeds where extraneous space
causes untidiness/havoc, i wonder whether it was a sensible decision.

>When working at a command line, spaces in file names are nothing
>but nuisances. Since there seem no cases where they must
>be used, I always advise they not be used.

me too, but remember that both systems that were responsible for
establishing the convention had command lines that were (at best) a
joke. (presumably macs now have decent shells, but when apple was
blazing a trail ...)

all very tiresome. i think we need to deal with it in latex, if we can.
--
Robin Fairbairns, Cambridge

0 new messages