monoceros84
monoceros84

Reputation: 118

TeX Interpreter in Matlab uiTable

I have created an uiTable in Matlab. Now I need to write column headers and some cell data, which contain greek letters and subscripts. In text objects or plots I would just enable the TeX interpreter - or it is even the default setting. This does not work in an uiTable. How would I do this here? Maybe pre-formatting the strings somehow?

If there would be a solution, the next question will be: I need this interpreter only in some cells (and column headers). Some other need to be printed as the strings are given. So basically, I would even need an individual TeX interpreter setting per cell. But I know this would be solvable by the correct string escaping...

Minimal example:

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

This looks like this. But it should be rather with an index "1" and an alpha character.

Upvotes: 0

Views: 2309

Answers (2)

Timo
Timo

Reputation: 1

Thanks for the str2html trick! For simple unicode symbols I came to this solution:

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

That will give symbol of ⇄.

Unicodes can be found here https://unicode-table.com/de/#21C4

Upvotes: 0

matlabgui
matlabgui

Reputation: 5672

You can use html and unicode char to do what you want in the column headers.

You could use the str2html FEX submission to create the html and you need to know the unicode char for the greek letters:

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>

This produces:

enter image description here

You can use the same theory to display in the individual cells:

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

Upvotes: 0

Related Questions