如何在MATLAB中使用LaTeX黑板字体? [英] How do you use the LaTeX blackboard font in MATLAB?
问题描述
因此,根据我的问题和解决方案,研究中,知道期望运算符可以像这样正常显示:
/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 包).
-
从此处下载AMS-LaTeX软件包.. p>
-
修改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\'; -
将AMS软件包中的所有
.sty
文件复制到MATLAB root\sys\tex
文件夹中. -
重新启动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:
Download the AMS-LaTeX package from here.
Modify the m-file
tex.m
, which is located in theMATLAB root\toolbox\matlab\graphics
folder (backup the file before modifying it):2.1. In the
localDecorateInputString
function, modifystandardhead
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\';Copy all
.sty
files of the AMS package to theMATLAB root\sys\tex
folder.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屋!