Pregunta

I have recently found that Matlab can use LaTeX character sequences. However, they only can be used by the functions text, title, xlabel, ylabel and zlabel. I have designed a GUI which has an uitable. Its header is a string that uses HTML code and looks like this:

headers = {'<html><center>Component X<br />(km/s^2)</center></html>', ...
           '<html><center>Component Y<br />(km/s^2)</center></html>', ...
           '<html><center>Component Z<br />(km/s^2)</center></html>'};

My intention is replacing s^2 with s squared. Because of I can not use LaTeX characters inside the string "header" (at least I have tried it and it has not worked), I would like to know how I could do it if I use HTML code which I do not know.

¿Fue útil?

Solución

For writing superscripts in HTML, use the <sup>...</sup> pair:

headers = {'<html><center>Component X<br />(km/s<sup>2</sup>)</center></html>', ...
           '<html><center>Component Y<br />(km/s<sup>2</sup>)</center></html>', ...
           '<html><center>Component Z<br />(km/s<sup>2</sup>)</center></html>'};

Otros consejos

For the superscripts appearing in units in diagram titles and labels I always use the designated Unicode characters like km/s² or kg/m³.
These numbers are available: ⁿⁱ⁰²³⁴⁵⁶⁷⁸⁹
This works even in software that does not allow LaTeX charactrer sequences (if the selected font has the corresponding characters and if the software is Unicode capable). The same numbers are available as subscript also.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top