latex interpreter sprintf issue
71 次查看(过去 30 天)
显示 更早的评论
Hi,
I would like insert text in my figure y = 10mm_x=1, I tried as follows, but it throws below error
Suggestions please !!
String scalar or character vector must have valid interpreter syntax: $Y= 10mm
text(0.7,1.05,(sprintf('$Y= 10mm\_{x} = %dmm$', i)),'FontSize',16,'Color','black','Interpreter','latex');
0 个评论
采纳的回答
Voss
2022-2-15
编辑:Voss
2022-2-15
Since there is a backslash (for the latex format) inside the sprintf format string, you must escape it (i.e., put another backslash before it) so that sprintf() doesn't interpret it as a format specifier:
i = 1;
text(0.7,1.05,(sprintf('$Y= 10mm\\_{x} = %dmm$', i)),'FontSize',16,'Color','black','Interpreter','latex');
更多回答(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!