How to put subscript in uilabel text and can I specify location on same line?

10 ビュー (過去 30 日間)
Paul
Paul 2022 年 12 月 21 日
回答済み: Paul 2022 年 12 月 21 日
I have the following (gl is a uigridlayout)
lblKa = uilabel(gl,"Text","K_a","HorizontalAlignment","center");
lblKa.Layout.Row = 2;
lblKa.Layout.Column = 4;
I am trying to subscript the "a" in "Ka". Also, is it possible to specify the layout row and column in a way that I can reduce three lines of code to one?

採用された回答

Jonas
Jonas 2022 年 12 月 21 日
for subscript, use other text interpreters, e.g. tex
uilabel("Text","K_a","HorizontalAlignment","center",'Interpreter','tex');
without beeing familiar with uigridlayout, i do not think, that it is possible that easily. But like it is, it is nicely readable
  1 件のコメント
Paul
Paul 2022 年 12 月 21 日
Thank you, that works BUT it also changes the font face so that the letter "K" appears differently from labels not using the tex interpreter. Any ideas on that?

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

その他の回答 (1 件)

Paul
Paul 2022 年 12 月 21 日
Jonas' answer got me to thinking about HTML and this works better for me because it does not mess with the font
uilabel(gl,"Text","<p>K<sub>a</sub></p>", "HorizontalAlignment","center",'Interpreter','HTML');
But I probably not come up with this without Jonas' suggestion. Thank you, Jonas

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by