comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: EPS fragment output for latex font interpretation?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: EPS fragment output for latex font interpretation? [message #54938] Wed, 25 July 2007 05:07 Go to previous message
Paolo Grigis is currently offline  Paolo Grigis
Messages: 171
Registered: December 2003
Senior Member
Gernot Hassenpflug wrote:
> Paolo_Grigis <pgrigis@astro.phys.ethz.ch> writes:
>
>> Gernot Hassenpflug wrote:
>>> Hello all,
>>>
>>> I have used IDL to output EPS figures with whatever fonts IDL has
>>> built-in. Now I would like to use IDL to output EPS fragments (in
>>> vector format) with markers for the text information, and .tex files
>>> containing the text corresponding to the markers, with both files to
>>> be later interpreted by LaTeX with an \input statement. With matlab,
>>> which I do not currently have a licence to, this was possible using
>>> the user-contributed laprint program.
>>>
>>> With such a splitting of the tasks, it is easy to adjust text size and
>>> font to what is required in the LaTeX document.
>>>
>>> Is there any way to do such a task in IDL (I have 6.2 and 6.3 licences
>>> at my workplace).
>>>
>>> Alternatively, if there is a way to use Computer Modern fonts with
>>> IDL, I could try to use those in the EPS file directly (then output in
>>> binary format is fine too).
>
> /../
>
>> I've done so in a few occasion, and it worked out fine.
>> Here's an example with IDL, LaTeX and unix commands, which
>> I put together with some help from this newsgroup a while ago:
>
> Many thanks! That is great news, my search of this group had turned up
> only mention of LaTeX package psfrag in 1997...
>
>> IDL commands to generate a figure with b and t as text markers:
>>
>> N=1000
>>
>> x=findgen(N)/(N-1)*10-5
>>
>> mu=0.
>> sigma=1.
>>
>> y=total(exp(-(x-mu)^2/(2*sigma^2)),/cumulative)*(x[1]-x[0])
>>
>> set_plot,'PS'
>> device,filename='fig1.eps',/encapsulated,xsize=12.,ysize=8.
>> !p.font=0
>
> I'll try this at work in the morning, for use. Is the setting of font
> to 0 one of the critical tricks?

Yes, I think it is. The point is that latex need to search and replace
your text labels, but it cannot find them if they are encoded as anything
different than plain text. Using device fonts should ensure that. I am
not sure exactly how to do the same using true type font...

>
>> plot,x,y,yrange=[0.,3.],thick=4,/xstyle,xrange=[-5,5],xtitle ='x',ytitle='y'
>> oplot,!X.crange,sqrt(2*!Pi)*sigma*[1,1],linestyle=2
>>
>> xyouts,0.,1.,'t',/data
>> xyouts,-3,2.65,'b'
>> device,/close
>> set_plot,'X'
>
> OK, understood.
>
>> ;END IDL
>>
>> LaTeX file:
>>
>> \documentclass{article}
>> \usepackage{geometry}
>> \usepackage{graphicx}
>> \usepackage{psfrag}
>> \pagestyle{empty}
>> \geometry{paperwidth=12.1cm,paperheight=8.1cm,margin=0pt}
>
> Excellent! So the below could be put into a separate .tex file and
> \input into the main document as I am used to doing under Matlab with
> the laprint program.
>
>> \begin{document}
>> \psfrag{t}[l][][1.35]{$\displaystyle y=\int_{-\infty}^x
>> e^{-\left(\frac{t-\mu}{\sqrt{2}\sigma}\right)^2}\,\mathrm{d} t$}
>> \psfrag{x}[c][][1.75]{$x$}
>> \psfrag{y}[c][][1.75]{$y$}
>> \psfrag{b}[c][][1.35]{$\displaystyle y=\sqrt{2\pi}\sigma$}
>> \includegraphics[width=11.9cm,height=7.9cm]{fig1.eps}
>> \end{document}
>
> Understood.
>
>> %end latex
>>
>>
>> Linux command to TEX and transform into eps:
>>
>> latex doc.tex
>> dvips -o fignew.ps doc.dvi
>
> Yes, OK.
>
>> ps2epsi fignew.ps fignew.epsi
>> perl -ne 'print unless /^%%BeginPreview/../^%%EndPreview/' < fignew.epsi > fignew.eps
>> rm fignew.epsi
>
> Ah, this part is new to me. Any idea what this is repairing, since
> you've already specified emcapsulated PS in your IDL program. (I
> understand the perl part after that to remove the preview TIFF image.)

Well, this is not really necessary, don't bother. Since dvips produces a
ps file, if you really want an eps you'll have to convert the ps to eps
in whatever manner you like (on my machine I just happen to have
ps2epsi available, so that's what I used). The reason for that is to
have a separate, final eps file with the figure *and* the latex
embellishments, which could afterwards be directly included into another
(either latex or non-latex) document without need for additional processing.

You're right about removing the preview, just save some disk space.


Ciao,
Paolo

>
>> Now you should have an eps file with equations rather than "t" and "b" labels...
>>
>> Hope this helps,
>> Paolo Grigis
>
> Fantastic! I'll let you know how this goes.
>
> Best regards,
> Gernot
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: CW_BGROUP and scrolling
Next Topic: Re: array subscript conversion

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 06:05:58 PDT 2025

Total time taken to generate the page: 1.92266 seconds