[OS X TeX] Changing texdoc behaviour

Roussanka Loukanova rloukano at stp.lingfil.uu.se
Wed Jan 31 02:39:43 CET 2007


Hi,

On Sun, 28 Jan 2007, Alan Munn wrote:

> At 11:23 PM -0500 1/28/07, Ettore Aldrovandi wrote:
>>>  At 10:26 PM -0500 1/28/07, Alan Munn wrote:
...
>>>  >#!/bin/sh
>>>  >FileName= `basename $1 .dvi`
>>>  >OutputFile= /var/tmp/$FileName.pdf
>>>  >dvipdf $FileName $OutputFile  | open -a Preview.app
>>>  >
>>>  >This seems to give the required behaviour.   Are there any obvious
>>>  >problems with doing this?
>>>
>>>  Ok, I'll stop wasting people's time reading my thinking out loud.
>>>  Sorry.  I had fooled myself into thinking this script worked, but it
>>>  doesn't.  But the idea is right, I guess.  If someone wants to bail
>>>  me out with a working script along these lines I'll be grateful.

I took all this seriously, because I myself have been trying it for 
awhile (and posted to the emacs list). Perhaps someone can help it out 
better than what I am getting, as follows:

>> 
>> Why the pipe in the last line? The output of dvipdf goes to
>> $OutputFile, not stdout. (Besides, I don't think open can be used
>> in that way: If I try "cat file.pdf|open -a preview" I only get
>> Preview.app to open.) Why not:
>> 
>> dvipdf $FileName $OutputFile
>> open -a preview $OutputFile

I modified your suggestions slightly to the following script
dvipdfPrev.sh

#!/bin/sh
# invoking: dvipdf FileName.dvi
FileName=`basename "$1" .dvi`
# the following 3 lines work:
# OutputFile="/var/tmp/${FileName}.pdf"
# dvipdf ${FileName}.dvi $OutputFile
# open -a Preview.app $OutputFile
# the following 2 lines work in the current dir:
dvipdf "$1"
open -a Preview "${FileName}.pdf"

This differs from your script by saving file.pdf in the current 
directory. Then, I created an AUCTeX/Emacs command dvipdfPrev under
emacs' menu Command; I made it the default View command for .pdf 
files.

Such default View overrides the original default xpdf in emacs. But each 
time when you would like to just open file.pdf in Preview from emacs, a 
new file.pdf would be also created.

One, may be clumsy, solution is:

- I added an auctex/emacs command Preview with the customization:

INS DEL Name: Preview
             Command: open -a Preview  %s.pdf
             How: Value Menu TeX-run-discard
             Start process with second argument, discarding its output.
             Prompt: Toggle  off (nil)
             Modes: Value Menu All
             Menu elements:
             INS

After creating file.pdf for a 1st time with dvipdfPrev, for subsequent 
views of file.pdf from emacs, I have to be careful to invoke the command 
Preview, instead View, from emacs' mini-buffer.

I can't get the default View to be sensitive to the presence of file.pdf, 
even by making Preview be the default View for .pdf files; and not even 
after deleting the file.dvi. I created for this purpose the following script:

latexdvipdf.sh

#!/bin/sh
# invoking: dvipdf basefname.tex
basefname=`basename "$1" .tex`
latex "$1"
dvipdf "${basefname}.dvi"
/bin/rm "${basefname}.dvi"

I put in my .bash_profile the following lines, but they do not affect the 
View commands from emacs:

export TEXDOCVIEW_pdf="open -a /Applications/Preview.app %s"
export TEXDOCVIEW_dvi="open -a /Applications/TeXShop.app %s"
export TEXDOCVIEW_html="open -a /Applications/Safari.app %s"
export TEXDOCVIEW_ps="open -a /Applications/TeXShop.app %s"

Some better suggestions?
Roussanka

------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/





More information about the macostex-archives mailing list