How to label the axes of a figure as Re and Im in the style of \mathfrak{Re} or \mathbb{Im} (from LaTeX \usepackage{})?
42 次查看(过去 30 天)
显示 更早的评论
Ironically the Insert LaTeX functionality (provided for by the live editor) produces the desired result, e.g.:
, but as far as I know this can not be utilized inside figures? Unfortunatley LaTeX packages which are not loaded in MATLAB by default are needed to use \mathfrak{}, \mathbb{} and \mathscr{}. I have done som digging, and from what I could gather it seems that the newer versions of MATLAB deals with LaTeX in a different manner than that of the earlier versions. Thus, the tex.m file cannot be edited to \usepackage{mathrsfs} and \usepackage{amssymb} as described here: https://stackoverflow.com/questions/12250919/how-do-you-use-the-latex-blackboard-font-in-matlab/12251619#12251619, and here https://tex.stackexchange.com/questions/98760/including-package-to-create-matlab-labels-using-latex/98803#98803. Is the \input and mwarticle.cls methods from the LaTeX Stack Exchange also obsolete? If not, how can they be used today? Are there any other methods which can be used to import/include LaTeX packages in MATLAB?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1180248/image.png)
If not, when did this change, and can I download a MATLAB version before this was changed, such that I can follow the guide from StackOverflow, and include the packages I need?
Other possible solutions (?):
1. Are there any fonts that matches what I am looking for? Can I download and use amsfonts directly, and use it in \fontname?
listfonts % prints out all available fonts
title('\fontname{Courier} Re') % maybe one of the fonts looks like what \mathbb{Re} or \mathfrak{Re} produces?
2. \Re and \Im with 'tex' yields ℜ and ℑ + some trick I am not familiar with to obtain𝔢 and ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1180253/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1180253/image.png)
(https://se.mathworks.com/help/matlab/creating_plots/greek-letters-and-special-characters-in-graph-text.html#mw_421aadf2-3104-41f5-ae7e-57bf5f7cdde3, link to the supported special characters for the 'tex' interpreter)
xlabel('\Re', 'interpreter', 'tex') % Output is a nice R
xlabel('\Re e', 'interpreter', 'tex') % Output is a nice R, but the e looks horribly out of place
ylabel('\Im', 'interpreter', 'tex') % Output is a nice I
ylabel('\Im m', 'interpreter', 'tex') % Output is a nice I, the m does not look good
Are there any methods to get the second characters looking like the first?
3. Unicode?
Not sure as to how this would be implemented, and which unicodes to use for a nice looking Re and Im, which fits into a LaTeX generated pdf.
4. matlab2tikz?
2 个评论
Walter Roberson
2022-11-4
Maybe one of
xlabel('$(A)\,\Re\textrm{e} (B)\,\Re\textsf{e} (C)\,\Re\texttt{e} (D)\,\Re\textbf{e} (E)\,\Re\textmd{e}$', 'interpreter', 'latex')
The font warning is from the textsf version.
Walter Roberson
2022-11-4
Unicode cannot be used with the LaTeX that Mathworks provides. Unicode can be used with interpreter 'tex' or 'none'
It looks like https://github.com/Happypig375/AMSFonts-Ttf-Otf contains amsfonts converted to TrueType (MATLAB needs TrueType)
采纳的回答
更多回答(1 个)
Santosh Fatale
2022-11-10
Hi Jorgen,
Following are answers to your questions:
- You can download the previous version of MATLAB from the following the steps mentioned in the answerHow do I download an older release of MATLAB? - MATLAB Answers - MATLAB Central (mathworks.com)
- Adding Latex packages is not currently possible with MATLAB version. This change has been made from R2013b.
- For the Latex symbol you are searching, you can try below code syntax.
plot(1:5, randi(10,1,5));
xlabel("\Ree \Imm", "Interpreter", "tex");
% No space between \Re and letter 'e' and same for \Im and letter 'm'
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 LaTeX 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!