matlab - 如何使用 LaTeX 解释器创建两行标题?

标签 matlab plot latex title

我在 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');

它的外观如下:

enter image description here

这最终将使每一行左对齐。如果您需要它们居中对齐,最简单的方法可能是使用 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/

相关文章:

matplotlib - Python 不断覆盖先前情节的 hist 但不使用所需的情节保存它

latex - RMarkdown : Auto Number Equations

python - 如何让 LaTeX 代码按字面意义存储在 Python 中?

Report/LaTeX 质量输出包

matlab - 在matlab中从对角线重建矩阵

matlab - 如何将监听器设置为 MATLAB 对象的结构字段

r - 绘制因子水平组的最小二乘均值

r - 在 R 中绘制有向多重图

image - 如何从此图像中删除此非红色和非圆形对象?把红色变成白色,其余的变成黑色

matlab - 如何将图像写入文件