Matlab uiTable中的TeX解释器

问题描述 投票:0回答:2

我在Matlab中创建了一个uiTable。现在我需要编写列标题和一些单元格数据,其中包含希腊字母和下标。在文本对象或图中,我只是启用TeX解释器 - 或者它甚至是默认设置。这在uiTable中不起作用。我怎么在这里这样做?也许以某种方式预先格式化字符串?

如果有解决方案,下一个问题将是:我只需要在某些单元格(和列标题)中使用此解释器。在给出字符串时需要打印其他一些。基本上,我甚至需要为每个单元格设置一个单独的TeX解释器。但我知道这可以通过正确的字符串转义来解决......

最小的例子:

h = figure();
t=uitable(h);
set(t,'ColumnName',{'test_1';'\alpha'})

This looks like this.但它应该是一个索引“1”和一个字母字符。

matlab tex matlab-uitable
2个回答
0
投票

您可以使用html和unicode char在列标题中执行所需操作。

你可以使用the str2html FEX submission来创建html,你需要知道希腊字母的unicode字符:

h = figure();
t=uitable(h);

str = str2html ( 'test', 'subscript', '1' );
set(t,'ColumnName',{str; char(945)})


Note: the html in this example is: <HTML>test<sub>1</sub></HTML>

这会产生:

enter image description here

您可以使用相同的理论在单个单元格中显示:

h = figure();
t=uitable(h);

str = str2html ( 'test', 'subscript', '1' );
Data{2,2} = str;
Data{3,3} = str2html ( 'test', 'superscript', '2' );
Data{4,1} = str2html ( '90', 'superscript', char(176) );
set(t,'ColumnName',{str; char(945); char(946)},'Data', Data)

enter image description here


0
投票

感谢str2html技巧!对于简单的unicode符号,我来到这个解决方案:

strUnicodeChar = char(hex2dec( '21C4' )); 

这将给出⇄的象征。

Unicodes可以在这里找到https://unicode-table.com/de/#21C4

© www.soinside.com 2019 - 2024. All rights reserved.