How to label the axes of a figure as Re and Im in the style of \mathfrak{Re} or \mathbb{Im} (from LaTeX \usepackage{})?
38 ビュー (過去 30 日間)
古いコメントを表示
Jørgen Myklebust
2022 年 11 月 4 日
編集済み: Jørgen Myklebust
2023 年 2 月 9 日
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?
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://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 で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!