有没有办法使用 TeX(希腊字母、下标、上标等)在 uicontrol 的静态文本中制作八度解释字符串?

Is there a way to make octave interpret strings in static text of uicontrol using TeX (Greek letters, subscripts, superscripts etc.)?

我正在用 GNU Octave (5.1.0) 编写 GUI。它应该读取一些输入值,进行一些计算,绘制一些图形并写出结果。除了 uicontrol 显示未解释的给定字符串(希腊字母、下标、上标等)这一不受欢迎的事实之外,一切都运行良好。有办法改变吗?

我尝试在 uicontrol 中指定解释器:

uicontrol ("parent", p, "style",'text', "string", ["\beta Q_v [m^3/s]"],'interpreter','tex']);

但是文档中没有这样的 属性,因此难怪我会收到此错误:

error: set: unknown uicontrol property interpreter

与此同时,我设法使用 UTF-8 ASCII 代码(在本例中为字母 beta)将希腊字母插入到显示的文本中:

uicontrol ("parent", p, "style",'text', "string", [char([206 178]) " Q_v [m^3/s]"],'interpreter','tex']);

效果很好。然而,变量及其单位的显示方式与它们在代码中的编写方式相同(没有下标,没有上标),这看起来有点傻,而且最重要的是 space 消耗。

自从我开始编写这个 GUI(2017 年左右)以来,我一直在网上搜索,但没有成功。好像从来没有人 运行 遇到过这种麻烦,这对我来说似乎很难运行。我错过了什么吗?任何帮助将不胜感激!

Octave 和 Matlab 都没有这个选项。但是,Pantxo 建议了一种解决方法,可以在 here 中找到。诀窍是 "fake text-style uicontrol using proper text objects".

简而言之,必须替换:

    uicontrol ("parent", p, "style",'text', "string", ...
    [char([206 178]) " Q_v[m^3/s]"], "position", [x0 y0 dx dy]);

    hax = axes ("parent", p,"visible", "off", "position", [0 0 1 1]); 
    text ("parent", hax, "units", "pixels", "position", [x0 y0 0], ... 
    "interpreter", "tex", "string", "\beta Q_v[m^3/s]", ... 
    "backgroundcolor", "none");

在字号等方面稍稍下了些功夫,结果还是很满意的。