Extra white spaces not inserted using the text command

I cannot get multiple spaces to show up on a plot when using the 'text' command.
For example, this works fine
c5 = strcat('$\rm{SW}$','{ }','$D_{\rm{max}}$','{ }','$v$');
l5 = text(0.9, 0.4, c5)
set(l5,'Interpreter','Latex','FontSize',10,'Color','b');
However, the extra white spaces as here do not show up
c5 = strcat('$\rm{SW}$','{ }','$D_{\rm{max}}$','{ }','$v$');
l5 = text(0.9, 0.4, c5)
set(l5,'Interpreter','Latex','FontSize',10,'Color','b');

 採用された回答

Jan
Jan 2021 年 4 月 23 日

1 投票

Yes, of course. The LaTeX interpreter ignores spaces. It is intented to do so.
Use the LaTeX command \hspace{} for horizontal blanks:
figure;
axes;
c5 = strcat('$\rm{SW}$','{\hspace{1cm}}','$D_{\rm{max}}$','{ }','$v$');
l5 = text(0.5, 0.5, c5)
set(l5, 'Interpreter', 'Latex', 'FontSize', 10, 'Color', 'b');

1 件のコメント

Tim Garrett
Tim Garrett 2021 年 4 月 26 日
Thanks. Very helpful, and of course was being a bit stupid. Sigh.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2020b

タグ

質問済み:

2021 年 4 月 23 日

コメント済み:

2021 年 4 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by