mathematica 8.0 和 psfrag

发布于 2024-11-15 22:21:16 字数 602 浏览 3 评论 0原文

我最近从 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 文件中编码文本的方式与早期版本相比是否有区别?

I recently updated from mathematica 7.0 to 8.0, and have now encountered problem with replacing my plot labels with LaTeX code using the psfrag package. Everything worked perfectly with the earlier version and the exact same plots, but now psfrag leaves all the labels unchanged. I use Kile on Ubuntu 11.04 for LaTeX editing.

For example, in Mathematica:

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

and then in LaTeX:

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

This should now replace labels with LaTeX typesetting, but nothing happens. Any suggestions how to solve this? Does anyone know if there is a difference in how Mathematica 8 encodes text in eps files compared to earlier versions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心在旅行 2024-11-22 22:21:16

EPS 的编码方式没有区别。问题是在 v7 输出中生成文本的 PS 代码(请注意,Mma 使用 bind 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}

注意:

可能想要使用 psfrag 的原因> 在 http://www.reimeika.ca/marco/prettyplots/ 中有很好的说明

现在,这些标签看起来不太好
(而且启动起来没什么意义)。
然而,这个想法最终是
将情节包含在论文或报告中
用 LaTeX 制作,所以真正的重点
标签就是将它们用作标记
对于 psfrag 包,它允许
替换 EPS 图表中的文本。这
标注方式有三大
与硬编码标签相比的优点
进入图中。首先是一致性,
因为字体将与那些相同
在文章中。其次是事实
LaTeX 的数学引擎可以
范围内得到最大程度的利用
情节。最后但并非最不重要的一点是,它
允许在内部轻松更改符号
.tex 文件,而不是必须
从头开始重新创建情节。


附录:

psfrag 包仅适用于 EPS 图形,因此仅适用于 latex
如果您想使用 psfragpdflatex,请参阅 tex.SE 问题
将 psfrag 与 pdflatex 结合使用

There's no difference in how the EPS is encoded. The problem is that the PS code that makes the text in the v7 output (note that Mma uses bind def to create shortcuts for a lot of PS code, see the top of the generated EPS files for details):

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

has been replaced in v8 with

%%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

This means that psfrag can not grab hold of the tags.
I can't find how to fix this in the Mma export options.

At the moment, the only work-around I can think of (and I've tested that works) is to use single letter tags for the axes labels, e.g.

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}

Note:

The reasons for maybe wanting to use psfrag are well stated in http://www.reimeika.ca/marco/prettyplots/

Now, those tags don’t look too good
(and make little sense to boot).
However the idea is to ultimately
include the plot in a paper or report
made with LaTeX, and so the real point
to the tags is to use them as markers
for the psfrag package which allows to
replace text within EPS graphs. This
way of labeling has three big
advantages over hardcoding the tags
into the figure. First is consistency,
as the fonts will be the same as those
in the article. Second is the fact
that LaTeX's mathematical engine can
be used to the fullest extent within
the plot. Last but not least, it
allows changing notation easily within
the .tex file, as opposed to having to
recreate the plot from scratch.


Addendum:

The package psfrag only works with EPS graphics and thus only with latex.
If you want to use psfrag and pdflatex, then see the tex.SE question
Using psfrag with pdflatex

一百个冬季 2024-11-22 22:21:16

尝试了 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}

因此,您必须手动完成一些工作,但通常值得花时间,因为结果看起来确实更好,特别是如果要发布的话。但是,请记住,在标准设置中,LaTeX 使用计算机现代字体作为公式。这与典型的文本选择(例如 Times New Roman)不同。您可以使用 mathptmx 包更改此设置。

Tried both 7.0.1 and 8.0.1 and worked well for me. Hence, I cannot reproduce your error. (Maybe just a typo, case sensitivity etc.). Anyway, I agree that LateX modification is almost obligatory for publications. First I also used PSFrag, but very often I also don't like the positioning of the labels, especially if you place more complex expressions. Therefore I suggest an intermediate step via PSTricks. This looks something like this:

\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.

一桥轻雨一伞开 2024-11-22 22:21:16

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

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

只要执行 [esc]+"eps"+[esc] 你就会得到一个 epsilon,或者从西格玛的工具箱也是如此。

You can write the "typeset" form in Mathematica directly, then it'll be already in the .eps file and you can just include the .eps as is.

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

Just do [esc]+"eps"+[esc] and you'll get an epsilon, or insert it from the toolbox. Same for the sigma.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文