MATLAB Answers

Error in the creation of a Greek letter in a GUI

5 views (last 30 days)
Jacopo
Jacopo on 23 May 2014
Commented: Igor Jasmim on 12 Oct 2016
Hello. I expose my question. I have tried to insert Greek letters in a static text following the procedure at the link:
I put in the Property Inspector in the entry "Tag" latex_text5 and under "String" \ alpha. However, in the command window I get the following warning:
Warning: Unable to interpret LaTeX string "\ alpha" > In openfig at 135    In gui_mainfcn> local_openfig at 286    In gui_mainfcn at 234    In GUI_prova2 at 42
What should I do to see the Greek letter alpha in the static text?
  6 Comments
Jacopo
Jacopo on 23 May 2014
This is what I wrote in the code, neither more nor less. I have also attached images of what appears before and after the run and what I wrote in the Property inspector.
% --- Executes just before GUI_prova2 is made visible.
function GUI_prova2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to GUI_prova2 (see VARARGIN)
% Choose default command line output for GUI_prova2
handles.output = hObject;
handles.laxis = axes('parent',hObject,'units','normalized','position',[0 0 1 1],'visible','off');
lbls = findobj(hObject,'-regexp','tag','latex_*');
for i=1:length(lbls)
l = lbls(i);
% Get current text, position and tag
set(l,'units','normalized');
s = get(l,'string');
p = get(l,'position');
t = get(l,'tag');
% Remove the UICONTROL
delete(l);
% Replace it with a TEXT object
handles.(t) = text(p(1),p(2),s,'interpreter','latex');
end
% Update handles structure
guidata(hObject, handles);

Sign in to comment.

Accepted Answer

dpb
dpb on 24 May 2014
Warning: Unable to interpret LaTeX string "\ alpha"
> In openfig at 135
In gui_mainfcn> local_openfig at 286
In gui_mainfcn at 234
In GUI_prova2 at 42
...What should I do to see the Greek letter alpha in the static text?
Well, I built a new GUI w/ just a single uicontrol and voila! was able to reproduce your error.
The problem is that for LaTeX the string '\alpha' must be in the math environment it turns out (enclosed in '$' signs. Otherwise, it's attempted to be interpreted in text mode and that fails spectacularly. Set the text in the Property Inspector to
This is a Greek alpha: $\alpha$
and joy will ensue...
Whew....learned something about LaTeX...
  3 Comments

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by