2015-11-06 124 views
3

我需要在MATLAB圖中創建一個雙行標題,在每行中使用LaTeX。LaTeX在MATLAB多行標題

title({'first line','second line'}) 

適用,但不適用於乳膠。在一行MATLAB標題,乳膠被理解爲在例如:

title(['$y=x^2$'],'interpreter','latex') 

我已經嘗試了許多東西,但我沒有設法有MATLAB產生與這些線膠乳中的多行標題。

回答

2

你可以用標題膠乳表格環境:

figure; 
plot((1:5).^2); 
title('\begin{tabular}{c}$y=x^2$ \\ $x=1, \ldots, 5$ \end{tabular}',... 
    'interpreter','latex') 
1

您可以使用sprintf創建的字符串爲title,明確將其換行字符,'\n'

title(sprintf('$y=x^3$\n$sin(x)$'), 'interpreter', 'latex'); 
5

如果運行

title({'$y=x^2$','$y=x^2$'},'interpreter','latex') 

你會得到正確使用乳膠ification一個兩行標題。

+0

也許你試圖執行一些格式不正確的LaTeX格式?如果您仍然遇到問題,請嘗試發佈失敗的實際LaTeX命令。此外,張貼您正在使用的MATLAB版本。 – gariepy

+1

在我看來,這是做到這一點的「正確」方式...... – RTL

+0

是的,比其他解決方案更清潔。不錯的工作。 – rayryeng