[OS X TeX] verbatim problems

Jens Noeckel noeckel at uoregon.edu
Thu Jul 6 05:44:36 CEST 2006


On Jul 5, 2006, at 7:27 PM, David Watson wrote:

> If the line endings are DOS, here is a little perl script to remove  
> them.
>
> #!/usr/bin/perl
> {
>     foreach $inFileName (@ARGV) {
>         open INTEXTFILE , $inFileName;
>         open OUTTEXTFILE, ">". $inFileName . ".con";
>         binmode OUTTEXTFILE;
>         binmode INTEXTFILE;
>         @textFile = <INTEXTFILE>;
>         foreach $textline (@textFile) {
>                 $textline =~ s/\x0d//g;
>                 print OUTTEXTFILE $textline ;
>         };
>         close (INTEXTFILE);
>         close (OUTTEXTFILE);
>         rename($inFileName,$inFileName . ".dos");
>         rename($inFileName . ".con",$inFileName);
>
>     }
> }
>
> Save this code to dos2unix.pl and run "chmod 755 dos2unix.pl".
>
> Run the code with your source file from the Terminal as follows:
> ./dos2unix.pl source
>
>

Or it's a problem with pre-OS X Mac line endings. If so, you could  
modify the above perl script, but I'd suggest an easier way:
Use the UNIX command "tr" to replace the special character ^M (or  
015) by UNIX line endings (012). The command for that would simply be

tr "\015" "\012" < INTEXTFILE > OUTTEXTFILE

where INTEXTFILE is the bad file and OUTTEXTFILE is the resulting  
fixed version.

I actually have this as a script called mac2unix, created analogously  
to what David described. Its content is a bit shorter -

#!/bin/csh
tr "\015" "\012" < $1 > $2

That's all - you'd invoke this with "mac2unix INTEXTFILE   
OUTTEXTFILE" from the Terminal command line. I remember using this a  
long time ago because TeX files from the old Mac OS were being  
typeset under OS X as if each line were a separate paragraph... (or  
something like that)... hope this helps with the verbatim problem, too.

OK - before sending this off I just checked if there's an _even_ more  
"user-friendly" solution because I recall that some people seem to  
dislike the command line... And indeed, there is a bona fide  
application that does this:
LineBreak, from http://www.trancesoftware.com/software/linebreak/

Have fun,

Jens

------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the macostex-archives mailing list