MATLAB:将 LaTeX 字符与轴标题中的数据格式相结合
MATLAB: Combining LaTeX characters with data formatting in axes title
我想弄清楚是否有办法通过 TeX 解释器将符号和数据输入组合成轴标题的单个字符串。
例如,我当前的代码是这样的:
figure
axHandle = axes;
appleTrees = 4;
s = sprintf( ...
'Apples vs Acres\nNumber of Apples Trees $\alpha = %2.0f$', appleTrees);
title(axHandle,s,'Interpreter','LaTeX')
我知道这行不通,但我认为它表达了我想要做的事情。
sprintf 导致以下消息:
Warning: Control Character '\l' is not valid.
See 'doc sprintf' for control characters valid in the format string.
我可以放弃 sprintf 并只使用引号,但是我失去了数据格式化/文本格式化功能。
反斜杠\
是Matlab中某些函数格式化字符串时的特殊字符。 sprintf
就是其中之一。要写反斜杠,请改用 \
。 Here 是其他特殊字符及其书写方式的列表。
对于您的情况,请使用以下行:
s = sprintf( ...
'Apples vs Acres\nNumber of Apples Trees $\alpha = %2.0f$', appleTrees);
我想弄清楚是否有办法通过 TeX 解释器将符号和数据输入组合成轴标题的单个字符串。
例如,我当前的代码是这样的:
figure
axHandle = axes;
appleTrees = 4;
s = sprintf( ...
'Apples vs Acres\nNumber of Apples Trees $\alpha = %2.0f$', appleTrees);
title(axHandle,s,'Interpreter','LaTeX')
我知道这行不通,但我认为它表达了我想要做的事情。
sprintf 导致以下消息:
Warning: Control Character '\l' is not valid.
See 'doc sprintf' for control characters valid in the format string.
我可以放弃 sprintf 并只使用引号,但是我失去了数据格式化/文本格式化功能。
反斜杠\
是Matlab中某些函数格式化字符串时的特殊字符。 sprintf
就是其中之一。要写反斜杠,请改用 \
。 Here 是其他特殊字符及其书写方式的列表。
对于您的情况,请使用以下行:
s = sprintf( ...
'Apples vs Acres\nNumber of Apples Trees $\alpha = %2.0f$', appleTrees);