Re: MacTeX and spaces in filenames



Enrico Gregorio <gregorio@xxxxxxxxxxxxx> wrote:

Steve Checkoway <scheckoway@xxxxxxxxx> wrote:

(Rowland McDonnell) wrote:
I've just come across a curiosity:

if I have a filename with a space (or more than one) in it, and I ask
for \jobname in my TeX input file, I get a filename rendered with
unsexed double quotation marks around it.

MacTeX 2006, MacOS 10.4.11.

Anyone got any idea why this effect happens, and if there's any way of
getting the double quote marks to just not appear when I ask for
\jobname?

In the preamble:
\def\firstchar#1#2\end{#1}
\def\parsejob"#1"{#1}%
\edef\unquotedjobname{%
\if"\expandafter\firstchar\jobname\end
\expandafter\parsejob\jobname
\else
\jobname
\fi
}

After \begin{document}
\let\jobname=\unquotedjobname

I'm not sure you actually want to change \jobname though. I don't know
what the ramifications of that are. I do know that if you put the \let
before \begin{document}, LaTeX fails.

There are consequences: for example, no .toc file is produced and the
table of contents comes out wrong. The failure when the \let is before
\begin{document} is actually due to the impossibility to produce the
right file name for the .aux file. In fact LaTeX asks to open an
output stream with the name resulting from \unquotedjobname, i.e.,

\immediate\openout\@mainaux abc def.aux

(assuming "abc def.tex" is the TeX file name, without quotes). Indeed
a file abc.tex appears in the file system. With

\immediate\openout\@mainoux "abc def".aux

everything works properly.

Apparently, when a file with spaces in the name is input, MacTeX
defines the expansion of \jobname with double quotes around it, in such
a way that the OS is happy when producing names for auxiliary files.

That makes good sense - I thought it was something like that.

This has no consequences when babel modules making the double quote
character active, since the expansion of \jobname consists of category
code 12 characters anyway.

One can use \unquotedjobname (without making \jobname equivalent to it)
if the unadorned file name is needed, but not for defining auxiliary
file names.

OTOH, we all know that spaces in the file name are evil. :-)

<chuckle> Quite right - which is how come it's only just now, when I
ended up using a filename with spaces in for anomalous reasons, that I
noticed this `issue'.

But for my purposes, changing \jobname isn't needed; I just need
`\jobname's expansion without the quotes around it'.

So \unquotedjobname seems to be just what I need - thanks!

Rowland.

--
Remove the animal for email address: rowland.mcdonnell@xxxxxxxxxxxxxxx
Sorry - the spam got to me
http://www.mag-uk.org http://www.bmf.co.uk
UK biker? Join MAG and the BMF and stop the Eurocrats banning biking
.



Relevant Pages

  • [PATCH] update checkpatch.pl to version 0.13
    ... This version brings a large number of fixes which have built up over ... prevent unclosed single quotes from spreading ... function brace checks should use any whitespece matches ... for my $filename { ...
    (Linux-Kernel)
  • Re: text file saved in COM format..
    ... caused it to run rather than opening in notepad. ... Try saving any file in notepad, it never suggests a filename ... i'm sure you mean double quotes. ... won't append any extension to the end of it. ...
    (microsoft.public.windowsxp.general)
  • Re: relative-to-source file names (was: Small, understandable Forth)
    ... source file currently being interpreted, the file is relative to the ... when the filename is enclosed in matching less than and  greater ... this search path). ... There's no need for multiple sets of quotes if the package refrains ...
    (comp.lang.forth)
  • Re: text file saved in COM format..
    ... caused it to run rather than opening in notepad. ... Try saving any file in notepad, it never suggests a filename ... i'm sure you mean double quotes. ... won't append any extension to the end of it. ...
    (microsoft.public.windowsxp.general)
  • Re: cgi using shell script : unexpected behavior
    ... quoted unless you want them to undergo word splitting and filename ... expansion. ... Hey thanks man! ...
    (comp.unix.shell)