我在 MATLAB 中画了一个图,标题很长,所以我决定将其分成两行。但是,当我使用 LaTeX 解释器时它不起作用。
标题代码行如下所示:
title('{Monte-Carlo For Both Linear and Non-Linear Models Using N=300 and An Adjoint Simulation;Frequency = 100Hz $\sigma_{T}=\sigma_{D}=10^{-5}$}','Interpreter','latex')
如何使其显示为 2 行并以 LaTeX 字体显示?
最佳答案
将字符串分解为cell array似乎工作得很好:
title({'Monte-Carlo For Both Linear and Non-Linear Models Using N=300' ...
'and An Adjoint Simulation; Frequency = 100Hz $\sigma_{T}=\sigma_{D}=10^{-5}$'}, ...
'Interpreter', 'latex');
它的外观如下:
这最终将使每一行左对齐。如果您需要它们居中对齐,最简单的方法可能是使用 tabular
environment根据Werner的建议:
title(['\begin{tabular}{c} Monte-Carlo For Both Linear and Non-Linear ' ...
'Models Using N=300 \\ and An Adjoint Simulation; Frequency = 100Hz ' ...
'$\sigma_{T}=\sigma_{D}=10^{-5}$ \end{tabular}'], ...
'Interpreter', 'latex');
如果您发现自己主要处理数学方程,几乎没有文本,那么 matrix
可能更合适(如果需要,使用 \textrm{...}
来转义文本):
title('$\matrix{\textrm{Some text} \cr \sigma_{T}=\sigma_{D}=10^{-5}}$', ...
'Interpreter', 'latex');
关于matlab - 如何使用 LaTeX 解释器创建两行标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47085142/