Center align multi-line title in latex format

23 ビュー (過去 30 日間)
AA
AA 2018 年 4 月 21 日
コメント済み: AA 2018 年 4 月 21 日
Hello, I would like to center align a multi-line title, but in latex format. I am currently using this
title_str1 = sprintf('$\\gamma=%s, k=%d, \\alpha_k=\\epsilon_k=%s=%s$', num2str(gamma), k, ...
func2str(alpha_k_fun), num2str(alpha_k));
title_str2 = sprintf('Trial-%d, $s_k=%d, a_k=%d$(%s)',trial, state_curr, a_k, A_actions{a_k});
title({title_str1, title_str2}, 'Interpreter', 'Latex', 'FontSize', 14); drawnow, hold off;
But, this makes the second line left-aligned. Any suggestions please?

採用された回答

Are Mjaavatten
Are Mjaavatten 2018 年 4 月 21 日

Using Latex forces left-alignment of lines in cell array of strings . (This may have been changed in the newest versions of Matlab. I use 2014b.) I think you can get most (or all) the effects you need by using the standard Tex formatting, which will center both lines. Example:

str1 = sprintf('\\gamma = %3.1f',1.4);
str2 = sprintf('s_k=%d, a_k=%d',2,3)
figure;title({str1,str2});
  1 件のコメント
AA
AA 2018 年 4 月 21 日
Thank you! It solved the purpose! However, LaTex looks a bit neater in terms of mathematical display. For e.g. the symbol 'k' is simply a text symbol now.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by