11

我最近从 Mathematica 7.0 更新到 8.0,现在遇到了使用 psfrag 包用 LaTeX 代码替换我的绘图标签的问题。一切都与早期版本和完全相同的情节完美配合,但现在 psfrag 保持所有标签不变。我在 Ubuntu 11.04 上使用 Kile 进行 LaTeX 编辑。

例如,在 Mathematica 中:

plot = Plot[x, {x, -0.1, 0.1}, 
            AxesLabel -> {eps, SUM}, BaseStyle -> {FontSize -> 10}]  
Export["plot.eps", plot]

然后在 LaTeX 中:

\begin{figure}   
\psfrag{eps}{$\epsilon$}  
\psfrag{SUM}{$\Sigma$}  
\includegraphics{plot.eps}  
\end{figure}  

现在应该用 LaTeX 排版替换标签,但没有任何反应。任何建议如何解决这个问题?有谁知道与早期版本相比,Mathematica 8 对 eps 文件中文本的编码方式是否有所不同?

4

3 回答 3

8

EPS 的编码方式没有区别。问题在于在 v7 输出中生成文本的 PS 代码(请注意,Mmabind def用于为许多 PS 代码创建快捷方式,有关详细信息,请参阅生成的 EPS 文件的顶部):

%%IncludeResource: font Times-Roman-MISO
%%IncludeFont: Times-Roman-MISO
10 /Times-Roman-MISO Msf
0 8 m
(SUM) N

已在 v8 中替换为

%%IncludeResource: font Times-Roman-MISO
%%IncludeFont: Times-Roman-MISO
10 /Times-Roman-MISO Msf
p
0.75 9 m
(S) N
P
p
6 9 m
(U) N
P
p
14.25 9 m
(M) N

这意味着psfrag无法抓住标签。我在 Mma 导出选项中找不到如何解决此问题。

目前,我能想到的唯一解决方法(并且我已经测试过)是使用单字母标签作为轴标签,例如

plot = Plot[x, {x, -0.1, 0.1}, AxesLabel -> {"e", "s"}, 
  BaseStyle -> {FontSize -> 10}]
Export["plot8.eps", plot]

\begin{figure}[h]
\psfrag{e}{$\epsilon$}
\psfrag{s}{$\Sigma$}
\includegraphics{plot8.eps}
\end{figure}

笔记:

可能想要使用的原因psfraghttp://www.reimeika.ca/marco/prettyplots/中有详细说明

现在,这些标签看起来不太好(而且启动起来也没什么意义)。然而,想法是最终将绘图包含在使用 LaTeX 制作的论文或报告中,因此标签的真正意义是将它们用作 psfrag 包的标记,该包允许替换 EPS 图中的文本。与将标签硬编码到图形中相比,这种标记方式具有三大优势。首先是一致性,因为字体将与文章中的相同。其次是 LaTeX 的数学引擎可以在情节中得到最大程度的使用。最后但同样重要的是,它允许在 .tex 文件中轻松更改符号,而不必从头开始重新创建绘图。


附录:

该软件包psfrag仅适用于EPS图形,因此仅适用于latex. 如果您想使用psfragand pdflatex,请参阅 tex.SE 问题 Using psfrag with pdflatex

于 2011-06-17T13:31:56.010 回答
4

尝试了 7.0.1 和 8.0.1,对我来说效果很好。因此,我无法重现您的错误。(也许只是一个错字,区分大小写等)。无论如何,我同意 LateX 修改对于出版物来说几乎是强制性的。首先我也使用了 PSFrag,但我也经常不喜欢标签的位置,尤其是当你放置更复杂的表达式时。因此,我建议通过 PSTricks 进行中间步骤。这看起来像这样:

\documentclass[floatfig,isolatin,amsthm,amsmath,amsfont,amstext,12pt,fullpage,pslatex,amsref]{scrartcl}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{float}
\usepackage{epic}
\usepackage{eepic}
\usepackage{color}
\pagestyle{empty}
\usepackage{pstricks}

\begin{document}

\begin{pspicture}(0,0)(13.0,7.8)

    %\psgrid(0,0)(0,0)(13,7.8)
% need the grid only in the beginning for positioning

    \rput[c](10.7,3.8){\includegraphics{plot.eps}}

% put labels. 

    \rput[c]{90}(9.5,4){\Large{$\frac{E^2_\text{tot}}{V M_\mathrm{S}}$}}
    \rput[c]{0}(6,6.0){$x/h$}

% also to put extra lines, arrows, comments, etc. in LaTeX style, e.g.:

%   \psline[linecolor=green,linewidth=2pt,linestyle=dashed]{->}(3.5,3.05)(9.1,3.05)
\end{pspicture}
\end{document}

So there is some work you have to do by hand, but usually it is worth the time as the result really looks better, especially if it is for publication. However, keep in mind that in standard settings LaTeX uses the Computer Modern Font for formulae. This is not identical with e.g. Times New Roman, the typical choice for text. You can change this with the mathptmx package.

于 2011-06-17T14:05:56.423 回答
1

您可以直接在 Mathematica 中编写“排版”表格,然后它已经在 .eps 文件中,您可以按原样包含 .eps 。

plot = Plot[x, {x, -0.1, 0.1}, AxesLabel -> {"[\eps], [\Sigma]}, BaseStyle -> {FontSize -> 10}]

只需执行 [esc]+"eps"+[esc] 即可获得一个 epsilon,或者从工具箱中插入它。西格玛也一样。

于 2011-06-17T12:13:54.177 回答