[Mac OS X TeX] TeXShop and BibTeX

Tom Kiffe tom at kiffe.com
Wed May 9 00:03:24 CEST 2001



I haven't looked at other scripts but here are two simple shell scripts I use for converting between Mac and Unix linebreaks.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
# mac2unix.sh
# convert Mac linebreaks to Unix linebreaks
foreach f ($argv[*])
	mv $f $f.mac
	cat $f.mac | tr "\r" "\n" > $f
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
If you run 

mac2unix.sh foo.tex

the script will save foo.tex as foo.tex.mac and then convert linebreaks.
When you are finished fo.tex will have Unix file breaks. If you type

mac2unix.sh *

the script will convert all the files in the current directory. 

For the reverse we have
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
# unix2mac.sh
# convert Unix linebreaks to Mac linebreaks
foreach f ($argv[*])
	mv $f $f.unix
	cat $f.unix | tr "\n" "\r" > $f
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Save each of these snippets in a separate file (with Unix linebreaks, 
a Catch22 situation). In the Terminal type

chmod 744 unix2mac.sh
chmod 744 mac2unix.sh

to make them executable and move them to your local bin. Type "rehash" and you can use them from the Terminal anywhere on your system.

Apple, in its infinite wisdom, decided a long time ago to make \r the
linebreak character on a Mac. Unix uses \n and Windows uses both. Since we
now have a hybrid system of Mac and Unix this is going to present numerous
little problems. Some of the TeX programs were designed to read both Mac
and Unix linebreaks. Bibtex and dvips, as generally distributed, do not.
Fortunately ghostscript does. If you begin to see unexpected behavior when
running a Unix program, linebreaks is one of the first things you should check.

I have been very careful with CMacTeX to make sure that it will handle both
Mac and Unix linebreaks. If anyone encounters this problem with one of my
programs, let me know so I can correct it.


>On Tuesday, May 8, 2001, at 05:27  PM, Arthur Ogus wrote:
>
>> I'm having the same trouble.  According to a local expert, the trouble
>> is the difference between LF (unix) and CR (Mac).  Bibtex expects
>> ASCII input which is limited to 1052 (?) characters per line.  If you have a mac file, everything appears on the same line to unix.
>>
>> I haven't experimented enough to be sure he is right.
>> -- Arthur Ogus
>>
>Thanks. Yes, he is right. I went back to 9.1 and opened both the .bib file and the particular .bst file I was using (which wasn't one of the .bst files in the standard distribution) in BBEdit and saved them with the option "Unix line breaks". Back to OS X and TeXShop and everything runs fine.
>
>Which brings me to the following: I seem to remember that there is a Unix script "mac2unix" that you can run in the command line to fix this problem of different ways of coding the line breaks. However it seems to be missing in OS X. Can anyone confirm its existence or even better, tell me where I can find it?
>


-----------------------------------------------------------------
To UNSUBSCRIBE, send email to <info at email.esm.psu.edu> with
"unsubscribe macosx-tex" (no quotes) in the body.
For additional HELP, send email to <info at email.esm.psu.edu> with
"help" (no quotes) in the body.
This list is not moderated, and I am not responsible for
messages posted by third parties.
-----------------------------------------------------------------




More information about the macostex-archives mailing list