Best practice for implementing LaTeX thin space within axis label
조회 수: 36 (최근 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?
댓글 수: 0
답변 (1개)
Sulaymon Eshkabilov
2023년 3월 26일
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
Sulaymon Eshkabilov
2023년 3월 28일
편집: Sulaymon Eshkabilov
2024년 9월 2일
\ in latex gives a single blank space between the symbols, briewfly speaking.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!