I'd like to plot a graph with y-label
with a Greek letter beta
. But in latex, I have the result present in the figure. How the latex interpret Greek letter?
My eps figure code is given by
%!PS-Adobe-3.0 EPSF-3.0
%%DocumentNeededResources: font Helvetica
%%+ font Helvetica-Bold
%%+ font Helvetica-Oblique
%%+ font Helvetica-BoldOblique
%%+ font Symbol
%%Title: R Graphics Output
%%Creator: R Software
%%Pages: (atend)
%%BoundingBox: 0 0 415 414
%%EndComments
%%BeginProlog
/bp { gs gs } def
% begin .ps.prolog
/gs { gsave } bind def
/gr { grestore } bind def
/ep { showpage gr gr } bind def
/m { moveto } bind def
/l { rlineto } bind def
/np { newpath } bind def
/cp { closepath } bind def
/f { fill } bind def
/o { stroke } bind def
/c { newpath 0 360 arc } bind def
/r { 4 2 roll moveto 1 copy 3 -1 roll exch 0 exch rlineto 0 rlineto -1 mul 0 exch rlineto closepath } bind def
/p1 { stroke } bind def
/p2 { gsave bg fill grestore newpath } bind def
/p3 { gsave bg fill grestore stroke } bind def
/p6 { gsave bg eofill grestore newpath } bind def
/p7 { gsave bg eofill grestore stroke } bind def
/t { 5 -2 roll moveto gsave rotate
1 index stringwidth pop
mul neg 0 rmoveto show grestore } bind def
/ta { 4 -2 roll moveto gsave rotate show } bind def
/tb { 2 -1 roll 0 rmoveto show } bind def
/cl { grestore gsave newpath 3 index 3 index moveto 1 index
4 -1 roll lineto exch 1 index lineto lineto
closepath clip newpath } bind def
/rgb { setrgbcolor } bind def
/s { scalefont setfont } bind def
% end .ps.prolog
%%IncludeResource: font Helvetica
/Helvetica findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding ISOLatin1Encoding def
currentdict
end
/Font1 exch definefont pop
%%IncludeResource: font Helvetica-Bold
/Helvetica-Bold findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding ISOLatin1Encoding def
currentdict
end
/Font2 exch definefont pop
%%IncludeResource: font Helvetica-Oblique
/Helvetica-Oblique findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding ISOLatin1Encoding def
currentdict
end
/Font3 exch definefont pop
%%IncludeResource: font Helvetica-BoldOblique
/Helvetica-BoldOblique findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding ISOLatin1Encoding def
currentdict
end
/Font4 exch definefont pop
%%IncludeResource: font Symbol
/Symbol findfont
dup length dict begin
{1 index /FID ne {def} {pop pop} ifelse} forall
currentdict
end
/Font5 exch definefont pop
%%EndProlog
%%Page: 1 1
bp
59.04 73.44 384.51 354.96 cl
0 setgray
0.75 setlinewidth
[] 0 setdash
1 setlinecap
1 setlinejoin
10.00 setmiterlimit
372.46 344.53 2.70 c p1
71.09 83.87 2.70 c p1
0.00 0.00 414.75 414.00 cl
0 setgray
0.75 setlinewidth
[] 0 setdash
1 setlinecap
1 setlinejoin
10.00 setmiterlimit
np
105.48 73.44 m
193.24 0 l
o
np
105.48 73.44 m
0 -7.20 l
o
np
202.10 73.44 m
0 -7.20 l
o
np
298.72 73.44 m
0 -7.20 l
o
/Font1 findfont 12 s
105.48 47.52 (0.80) .5 0 t
202.10 47.52 (0.85) .5 0 t
298.72 47.52 (0.90) .5 0 t
np
59.04 84.65 m
0 255.13 l
o
np
59.04 84.65 m
-7.20 0 l
o
np
59.04 127.17 m
-7.20 0 l
o
np
59.04 169.69 m
-7.20 0 l
o
np
59.04 212.21 m
-7.20 0 l
o
np
59.04 254.73 m
-7.20 0 l
o
np
59.04 297.25 m
-7.20 0 l
o
np
59.04 339.78 m
-7.20 0 l
o
41.76 84.65 (0.3) .5 90 t
41.76 127.17 (0.4) .5 90 t
41.76 169.69 (0.5) .5 90 t
41.76 212.21 (0.6) .5 90 t
41.76 254.73 (0.7) .5 90 t
41.76 297.25 (0.8) .5 90 t
41.76 339.78 (0.9) .5 90 t
np
59.04 73.44 m
325.47 0 l
0 281.52 l
-325.47 0 l
0 -281.52 l
o
0.00 0.00 414.75 414.00 cl
/Font1 findfont 12 s
0 setgray
207.10 18.72 (y) 0 ta
-0.240 (ears) tb gr
12.96 214.20 (dollar \($\beta$\)) .5 90 t
ep
%%Trailer
%%Pages: 1
%%EOF
Best Answer
It is possible to interpret LaTeX code in EPS files directly with the package
psfrag
. This package defines a command\tex
that can be used inside an EPS file, with backslashes escaped. However, it is not very convenient to use. The command can only be used for a complete PostScript command (so not for a part of a string only, as in the example). Besides, getting the right positioning and font size is difficult. Third, you need a more complicated way of compiling the LaTeX document, either usinglatex-dvips-ps2pdf
or withauto-pst-pdf
andshell-escape
.Example modification to the postscript file (near the end):
LaTeX document (compile with
pdflatex --shell-escape myfile.tex
):Result:
However, given that the graph is made in R, there are other ways to get LaTeX and/or Greek letters in the output. One way is to use the library
tikzDevice
, which outputs TikZ code. In R:LaTeX:
Result:
Alternatively, you can use Greek letters directly in R, when using the
Cairo
library for PDF output:Result: