26 views

Uploaded by dearprasanta6015

this document desribes the way to write latex equations inside a figure drawn in Xfig.

save

- Flow Diagram
- MultiMarkdown User's Guide - Fletcher T. Penney
- Latex 87
- R05
- cntrl_gs
- SCME-2006-08-30
- FAQ
- Instructions for publishing in a Russian Journal
- matlab-plotting 3d spheres.pdf
- derivadas_parciales_matlab
- Last Page
- Getting Started With Texmaker
- 19.Mobile Printing Solutions.full
- SI CDI Assignment2
- Data Acquisition Toolbox
- COMPUTER APPLICATIONS IN CHEMICAL ENGINEERING
- Matlab
- Readme
- Winter 09 Os Lab Material
- MATLAB Programming Fundamentals - Matlab_prog
- Design and Development of a Framework for HIL Testing of Digital Hardware With MATLAB
- Channel Estimation Final1
- runall
- MATLAB_SIMULINK main
- In Edg Crp 2016-17 Ws - Offline - Master
- May 12 2015 Advanced Matlab
- Fixed-Point Designer™ User’s Guide
- ahmadamirulaminaa060012d10ttt
- Lung cancer detection using digital image processing
- Abf
- MATLAB Workshop
- 400_0089.pdf
- MITRES_6_007S11_lec03
- Digital Frequency
- MITRES_6_007S11_lec01
- micro_GA
- Global System for Mobile Communications
- ofdm signal
- Bjt Fet Question
- small introduction to basics of MATLAB
- Dsp n06 Chapter6
- SmartTech - Make In India CLOUD_final.pdf
- matlab
- Frequency in discrete systems
- MITRES_6_007S11_lec02
- ICES_2011_NITR
- 8 Kundur Overlap Save Add
- Rules for M.tech NIT_printed Ver_1_51
- frc_labVIEW
- Mantra
- Coding and Compression
- Matlab 2
- 00599999
- Sanskrit Ref Manual
- Channel Print
- ECD4 Freq Response
- ebooksclub.org__Fundamentals_of_Statistical_Signal_Processing__Volume_I__Estimation_Theory___v__1_
- Ch3_notes
- chan_est

A

T

E

X in your Postscript ﬁles

Programs which generate Postscript (ps) or Encapsulated Postscript (eps) output, such as MATLAB or xﬁg, are

somewhat limited in their ability to produce mathematical expressions. For example, the current version of MATLAB

has no easy provision for combining regular text and Greek symbols, equations, subscripts, etc., for axes labels or

for plot legends. Although xﬁg allows you to create these marvels by hand, it is more eﬃcient to incorporate L

A

T

E

X

typesetting commands into your ﬁgure. The psfrag macro allows any string in a ps or eps ﬁgure to be replaced with

L

A

T

E

X generated text. This handout shows you how to do it. An example using a MATLAB plot is given, but you

can use the same tricks with any eps ﬁle.

Generating the MATLAB plot

You probably know how to generate a MATLAB plot and store it using the print command. To get axes labels on

the plot using L

A

T

E

X, you have to label the axes slightly diﬀerently. For example, if you want the X–axis label as

“Fancy X–label:

∞

−∞

f(t) dt”, type the following (in MATLAB):

>> xlabel(’xl’)

Now we have to replace xl with “Fancy X–label:

∞

−∞

f(t) dt”. This is done using the \psfrag command. This

command is to be used in the L

A

T

E

X source ﬁle. Its syntax is:

\psfrag{name}[position][psposition][scale][rot]{LaTeX text}

As an example, consider \psfrag{xl}[c]{Fancy X--label: $\int_{-\infty}^{\infty} f(t)\,dt$}, which will

be a line in your L

A

T

E

X source ﬁle. This will replace every occurrence of xl that appears in the MATLAB plot

with “Fancy X–label:

∞

−∞

f(t) dt”. In a similar vein, if you want to label a graph A

2

(n), then place a string p1

in a suitable location inside the plot (using either MATLAB’s text or gtext command). Once the sequence of

commands given below are executed, the ﬁnal PostScript ﬁle should contain the plot with the legend A

2

(n). In the

L

A

T

E

X command \psfrag{p1}[c]{$A_2(n)$}, the option [c] will center the replaced string around p1. If you want

the replacement string to be right-justiﬁed, then the option should be [r]. (No prizes for guessing what the option

is for left-justifying the text.)

Figure 1 shows the MATLAB plot as it would appear before replacing the strings. (These strings will later be

replaced with L

A

T

E

X text.) The ﬁrst thing to do is to save the ﬁgure as an eps ﬁle. This is done using the MATLAB

0 50 100 150 200 250 300 350 400

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

y

l

xl

p1

Figure 1: MATLAB plot as it appears on your screen.

command

>> print -deps2 figure.eps

This will generate the ﬁle figure.eps. Next, use the command (outside MATLAB, of course) ps2frag on the ﬁle

just created:

ps2frag figure.eps

Additions needed in the L

A

T

E

X source ﬁle

The L

A

T

E

X source ﬁle has to be modiﬁed slightly before you can accomplish string replacement on .eps ﬁles. The

package psfrag has to be included using the usepackage command: \usepackage{psfrag}.

The following is a portion of a L

A

T

E

X ﬁle example.tex. The \psfrag commands between the \begin{figure}

and \end{figure} are the ones that take care of string replacement. The \includegraphics is needed for including

the EPS ﬁle figure.eps into the L

A

T

E

X document.

\documentclass[11pt]{article}

\usepackage{rotating,graphics,psfrag,epsfig}

..........

\begin{figure}[h!t]

\centering

\psfrag{xl}[c]{\footnotesize Fancy X--label: $\int_{-\infty}^{\infty} f(t)\,dt$}

\psfrag{yl}[c]{\footnotesize Fancy Y--label: $\sum_{n=-\infty}^{\infty} f[n]$}

\psfrag{p1}[c]{\begin{turn}{75} \footnotesize Dangerously Leaning Tower of

$\pi\iota\sigma\alpha$ \end{turn}}

\resizebox{3.0in}{!}{\includegraphics{figure.eps}}

\caption{An example of string replacement using \texttt{psfrag}.}

\end{figure}

The following commands are needed to obtain the ﬁnal output: (1) latex example.tex (2) dvips example.dvi.

The PostScript ﬁle example.ps will contain the L

A

T

E

X output and ﬁgures in the ﬁnal form.

To summarize the steps required to iuse psfrags:

1. Store the MATLAB plot using the print -deps2 filename.eps command.

2. Use the ps2frag command on the EPS ﬁle.

3. L

A

T

E

X your source ﬁle; the source ﬁle should contain string replacements using the \begin{psfrag} commands.

4. Run dvips to get the postscript ﬁle.

5. Preview the ﬁle with ghostview to see if the string replacements have been done properly, before printing the

document.

Figure 2 is a sample output in which the strings have been replaced with the desired L

A

T

E

X text.

0 50 100 150 200 250 300 350 400

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

PSfrag replacements

Fancy X–label:

∞

−∞

f(t) dt

F

a

n

c

y

Y

–

l

a

b

e

l

:

∞n

=

−

∞

f

[

n

]

D

a

n

g

e

r

o

u

s

ly

L

e

a

n

in

g

T

o

w

e

r

o

f

π

ι

σ

α

Figure 2: An example of string replacement using psfrag.

- Flow DiagramUploaded byhkajai
- MultiMarkdown User's Guide - Fletcher T. PenneyUploaded bycassiocv
- Latex 87Uploaded byRicardo Cezar Volert
- R05Uploaded byssingaram1965
- cntrl_gsUploaded bybalu_upp
- SCME-2006-08-30Uploaded byMarius Ferdy
- FAQUploaded byEduardo Diniz
- Instructions for publishing in a Russian JournalUploaded byfcofimeuanl
- matlab-plotting 3d spheres.pdfUploaded bySaurabh Tewari
- derivadas_parciales_matlabUploaded byYeray Marrero Castillo
- Last PageUploaded bymyasmreg
- Getting Started With TexmakerUploaded byNehaKarunya
- 19.Mobile Printing Solutions.fullUploaded byTJPRC Publications
- SI CDI Assignment2Uploaded byعبد الحفيظ بن يونس
- Data Acquisition ToolboxUploaded byRR886
- COMPUTER APPLICATIONS IN CHEMICAL ENGINEERINGUploaded byKeziah Lynn Bautista
- MatlabUploaded byobsecur
- ReadmeUploaded byRicardo Trejo
- Winter 09 Os Lab MaterialUploaded byrockin_ravi_vit
- MATLAB Programming Fundamentals - Matlab_progUploaded byJérôme Kyabu
- Design and Development of a Framework for HIL Testing of Digital Hardware With MATLABUploaded bynileshchaurasia
- Channel Estimation Final1Uploaded byAnkit Prasad
- runallUploaded byGingramF
- MATLAB_SIMULINK mainUploaded byrajendra88
- In Edg Crp 2016-17 Ws - Offline - MasterUploaded byPawan Singh
- May 12 2015 Advanced MatlabUploaded byyasir hamid
- Fixed-Point Designer™ User’s GuideUploaded byVictor Colpo Navarrete
- ahmadamirulaminaa060012d10tttUploaded byDuke
- Lung cancer detection using digital image processingUploaded bypandi
- AbfUploaded byDavidWebb

- MATLAB WorkshopUploaded bydearprasanta6015
- 400_0089.pdfUploaded bydearprasanta6015
- MITRES_6_007S11_lec03Uploaded bydearprasanta6015
- Digital FrequencyUploaded bydearprasanta6015
- MITRES_6_007S11_lec01Uploaded bydearprasanta6015
- micro_GAUploaded bydearprasanta6015
- Global System for Mobile CommunicationsUploaded bydearprasanta6015
- ofdm signalUploaded bydearprasanta6015
- Bjt Fet QuestionUploaded bydearprasanta6015
- small introduction to basics of MATLABUploaded bydearprasanta6015
- Dsp n06 Chapter6Uploaded bydearprasanta6015
- SmartTech - Make In India CLOUD_final.pdfUploaded bydearprasanta6015
- matlabUploaded bydearprasanta6015
- Frequency in discrete systemsUploaded bydearprasanta6015
- MITRES_6_007S11_lec02Uploaded bydearprasanta6015
- ICES_2011_NITRUploaded bydearprasanta6015
- 8 Kundur Overlap Save AddUploaded bydearprasanta6015
- Rules for M.tech NIT_printed Ver_1_51Uploaded bydearprasanta6015
- frc_labVIEWUploaded bydearprasanta6015
- MantraUploaded bydearprasanta6015
- Coding and CompressionUploaded bydearprasanta6015
- Matlab 2Uploaded bydearprasanta6015
- 00599999Uploaded bydearprasanta6015
- Sanskrit Ref ManualUploaded bydearprasanta6015
- Channel PrintUploaded bydearprasanta6015
- ECD4 Freq ResponseUploaded bydearprasanta6015
- ebooksclub.org__Fundamentals_of_Statistical_Signal_Processing__Volume_I__Estimation_Theory___v__1_Uploaded bydearprasanta6015
- Ch3_notesUploaded bydearprasanta6015
- chan_estUploaded bydearprasanta6015