如何在MATLAB中使用LaTeX黑板字体? [英] How do you use the LaTeX blackboard font in MATLAB?

查看:543
本文介绍了如何在MATLAB中使用LaTeX黑板字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,根据我的问题和解决方案,研究中,知道期望运算符可以像这样正常显示:

/mathbb{E} 

但是,当我尝试在MATLAB中使用它时,什么也没打印出来.

clear all
figure(1); clf(1);
set(gcf, 'color', 'white'), axis off     %# Remove axes and set white background
my_text = '$$ \mathbb{E} $$';
text('units', 'inch', 'position', [-0.5 3.5], 'fontsize', 14, 'color', 'k', ...
    'interpreter', 'latex', 'string', my_text);

现在,我知道\ mathbb是某种不同的库",但是坦率地说,它对于数学公式非常有用.如何在MATLAB中包含"它?我对此不知所措.

解决方案

您可能没有注意到它,但是在命令提示符下收到警告消息:

Warning: Unable to interpret TeX string

告诉您MATLAB无法解析您的LaTeX表达式.更具体地说,MATLAB不支持黑板粗体数学字体(由'\mathbb'指示).内置LaTeX解释器(需要 amsmath 包).

此处此处.我为您总结一下:

  1. 此处下载AMS-LaTeX软件包.. p>

  2. 修改m文件tex.m,该文件位于MATLAB root\toolbox\matlab\graphics文件夹中(在修改文件之前先对其进行备份):

    2.1.在localDecorateInputString函数中,修改standardhead以包括新软件包(以粗体标记):

    standardhead = [' \nofiles \documentclass{mwarticle} \usepackage{amsfonts, amsbsy, amssymb} \begin{document}']

    2.2.在localGetTeXPath函数中,添加AMS软件包文件所在的路径(以粗体标记),例如:

    texpath{1} = blah blah blah...
    texpath{end+1} = blah blah blah...
    texpath{end+1} = 'C:\amslatex\';

  3. 将AMS软件包中的所有.sty文件复制到MATLAB root\sys\tex文件夹中.

  4. 重新启动MATLAB.

您现在应该已经安装了必要的LaTeX字体包.如果时间允许的话,我本来会很乐意亲自检查的,这似乎很有希望.

So, based on my question and solutions here, I would like to actually start using LaTeX, in figures as seen. However, one problem I am running into, is that I cannot seem to display the Expectation operator.

From my research, I know that the expectation operator can be displayed as such normally as such:

/mathbb{E} 

However, when I try to use it in MATLAB, nothing prints out.

clear all
figure(1); clf(1);
set(gcf, 'color', 'white'), axis off     %# Remove axes and set white background
my_text = '$$ \mathbb{E} $$';
text('units', 'inch', 'position', [-0.5 3.5], 'fontsize', 14, 'color', 'k', ...
    'interpreter', 'latex', 'string', my_text);

Now, I know that the \mathbb is some sort of different 'library', but frankly it is quite useful for mathematical formulations. How do I 'include' it in MATLAB? I am lost on this.

解决方案

You might not have noticed it, but you get an warning message in the command prompt:

Warning: Unable to interpret TeX string

which tells you that MATLAB has trouble parsing your LaTeX expression. More specifically, the blackboard bold math font (indicated by the '\mathbb') is not supported by MATLAB's built-in LaTeX interpreter (it requires the amsmath package).

One way to install this package is described here and here. I'll summarize it for you:

  1. Download the AMS-LaTeX package from here.

  2. Modify the m-file tex.m, which is located in the MATLAB root\toolbox\matlab\graphics folder (backup the file before modifying it):

    2.1. In the localDecorateInputString function, modify standardhead to include the new packages (marked in bold):

    standardhead = [' \nofiles \documentclass{mwarticle} \usepackage{amsfonts, amsbsy, amssymb} \begin{document}']

    2.2. In the localGetTeXPath function, add the paths of where the AMS package files are located (marked in bold), for instance:

    texpath{1} = blah blah blah...
    texpath{end+1} = blah blah blah...
    texpath{end+1} = 'C:\amslatex\';

  3. Copy all .sty files of the AMS package to the MATLAB root\sys\tex folder.

  4. Restart MATLAB.

You should now have the necessary LaTeX font packages installed. I would've gladly checked it out myself if time allowed, it seems promising.

这篇关于如何在MATLAB中使用LaTeX黑板字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆