Re: [OS X TeX] failure when using »&« in path names

Ross Moore ross at ics.mq.edu.au
Sat Aug 29 00:53:51 CEST 2009


Hi Friedrich

On 28/08/2009, at 11:28 PM, RA Friedrich Vosberg wrote:

> Morning.
>
> How should I modify the attached below home brewed package to add  
> path and file names, so that no failure occurs if a path name  
> contains the letter »&«.


You will need to adjust the \catcode of  '&'  so that it looks
like an ordinary character, rather than having the special status
that TeX endows it, as a delimiter between table cells.

But only do this within a \begingroup ... \endgroup  grouping,
so that it behaves as TeX expects outside of this grouping.

>
> \NeedsTeXFormat{LaTeX2e}
> \ProvidesPackage{pathfile}[2007/04/19 v0.2.0.0 Friedrich Vosberg]
> \RequirePackage{xspace}
> % 
> %--------------------------------------------------------------------- 
> ---------
> \begingroup
          \catcode`\& 12  %  this should ensure the '&' behaves as  
desired --- RRM
> 	\let\\\relax
> 	\immediate\write18{%
> 		pwd | sed -e 's/&/\\&/g' | iconv -f UTF-8-MAC -t MacRoman | awk - 
> F'\\n' '{%
> 			print"
> 				\\begingroup
					 \\catcode\\\`&=12\\relax
> 					\\catcode\string^\string^60\\\string^\string^24=11\\relax
> 					\\catcode\string^\string^60\\\string^\string^26=11\\relax
> 					\\newcommand\\fvpath{" $1 "\\xspace}\\relax
> 					\\expandafter
> 				\\endgroup
> 				\\expandafter\\newcommand
> 				\\expandafter\\fvpath
> 				\\expandafter{\\fvpath}\\relax
> 				\\endinput"
> 			}'
> 		> tmppath.tex%
> 	}
> 	\immediate\write18{%
> 		echo "\jobname" | sed -e 's/&/\\&/g' | iconv -f UTF-8-MAC -t  
> MacRoman | awk -F'\\n' '{%
> 			print"
> 				\\begingroup
					 \\catcode\\\`&=12\\relax
> 					\\catcode\string^\string^60\\\string^\string^24=11\\relax
> 					\\catcode\string^\string^60\\\string^\string^26=11\\relax
> 					\\newcommand\\fvfile{" $1 "\\xspace}\\relax
> 					\\expandafter
> 				\\endgroup
> 				\\expandafter\\newcommand
> 				\\expandafter\\fvfile
> 				\\expandafter{\\fvfile}\\relax
> 				\\endinput"
> 			}'
> 		> tmpfile.tex%
> 	}%
> \endgroup
> \input{tmppath.tex}
> \input{tmpfile.tex}
> \newcommand*{\pathfile}[1][pdf]{%
> 	\frenchspacing\fvpath/\fvfile{}.#1%
> }
> %% 
> ====================================================================== 
> ========
> % 2006/04/05 v0.1.0.0 initial release
> % 2007/04/19 v0.2.0.0 frenchspacing in \newcommand{\pathfile}{}  
> added----------- Please Consult the Following Before Posting  
> -----------
> TeX FAQ: http://www.tex.ac.uk/faq
> List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
> List Archive: http://tug.org/pipermail/macostex-archives/
> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
> List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex
>


I've not checked this with any testing.
Hopefully there is the right number of \ characters in the lines:
       \\catcode\\\`&=12\\relax
to properly escape the ` (backquote) character.


Anyway, you should understand the problem now, and get it sorted out
for yourself.


Hope this helps,

	Ross

------------------------------------------------------------------------
Ross Moore                                       ross at maths.mq.edu.au
Mathematics Department                           office: E7A-419
Macquarie University                             tel: +61 (0)2 9850 8955
Sydney, Australia  2109                          fax: +61 (0)2 9850 8114
------------------------------------------------------------------------






More information about the macostex-archives mailing list