Best practice for implementing LaTeX thin space within axis label

40 次查看(过去 30 天)
The following formulation for a mixed latex and non-latex string to be rendered with the latex interpreter works well; the rendered output is exactly as I expect.
x_label_str = ['time [', '$\,$', 's', '$\,', ']'];
y_label_str = ['intensity [', '$\,{\mu}$', 'V', '$\,$', ']'];
Matlab, however responds with:
Warning: Error updating Text.
String scalar or character vector must have valid interpreter syntax
When one replaces \, with \hspace{0.5em} for example, the same response is returned by the compiler.
Why? And is there a better approach for the same effect?

回答(1 个)

Sulaymon Eshkabilov
Here is the solution:
t=linspace(0, 2*pi);
h = sin(t);
figure
plot(t,h)
xlabel('$time \ [ \ s\ ]$', 'Interpreter','latex');
ylabel('$intensity \ [ \ \mu V\ ]$', 'Interpreter','latex');
  2 个评论
Chris L'Esperance
Chris L'Esperance 2023-3-28
Thanks for the reply! What is the reasoning behind the \ symbols? The objective is to render the parameter name text outside of the strings which are rendered as math, hence the comma strings within the array of strings. Note that the .pdf resulting from a call from a function such as export_fig must preserve the formatting / spacing appearing in the MATLAB figure window.
Sulaymon Eshkabilov
编辑:Sulaymon Eshkabilov 2024-9-2
\ in latex gives a single blank space between the symbols, briewfly speaking.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by