What works in 2024 stopped with 2025: Latex interpreter
Show older comments
The following (\textcircled and \fbox) used to produce circled and boxed text on axes in MATLAB 2024 and earlier versions. Can you tell what might have happened and/or a specific setting that would restore? Or is there an alternative efficient way (instead of writing lines of code and using graphics) to get circled/boxed text?
My original source was : https://stackoverflow.com/questions/10818392/matlab-putting-a-circled-number-onto-a-graph
I realize that latex support in MATLAB may be somewhat limited, but I wish that what worked before still works.
Thank you all in advance...
GP--
text(0.5,0.5,[' ' ' $\raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {' num2str(14) '}}}$' ' :i-end'],...
'Units','normalized','HorizontalAlignment','left','VerticalAlignment', 'bottom', 'Color','m',...
'Interpreter','latex',"FontSize",14);
text(0.2,0.5,['$\fbox{ ' num2str(25) ' }$' ],...
'HorizontalAlignment','center','VerticalAlignment', 'top','rotation',40,...
'Interpreter','latex',"FontSize",11);


7 Comments
Here is the actual list of supported LaTex commands:
I don't know why certain commands have been removed in the recent release. You should contact MATLAB support for an answer:
"...why certain commands have been removed in the recent release."
No way to know unless/until Mathworks will respond to a support request, but I wonder if it might be owing to the judgement by someobody that the particular function is pretty ugly in the circled text so they decided nobody would want to use it anyway...but it does seem to be another case of arbitrarily removing functionality instead of letting the user decide.
Interesting that the link to the supported LaTeX commands is in the section specifically addressing only the insertion of equations into the Live Editor as if Mathworks doesn't really care about its general use outside formatting m-files.
The example code from @Gokhan Pekcan's post seems to have come from a thread on the TeX section of StackExchange <Good way to make \textcircled numbers?> where the examples are embedded in one of the many answers that attempts to improve appearance by adjusting baseline of the number inside the circle. There appears to have been no perfect solution using the builtin LaTeX with several other submissions of alternates but unless one could manage to add a package or write ones own with the embedded LaTex distributed by Mathworks, it wouldn't appear possible to use any of them.
If they would document how to load a package to the distributed implementation it would be agoodthing™, but being a really good-looking solution or not, I don't see why Mathworks should purposefully neuter a standard LaTeX distribution.
dpb
on 13 Oct 2025
Sorta' what I figured; admitting guilt isn't in the normal response repertoire... <g>
It appears Mathworks has deliberately removed all extended LaTeX functionality except the specific list of symbols and operators along with some equation-setting math construct commands. All other base LaTeX commands have been expunged or at least made inaccessible to the user. This allows for the apparent intent of using LaTeX as a script formatting tool cover most ordinary code constructs, but as with any other limits placed on the user, prevents any extension beyond one envisioned by the code developers. This is the same type of limitation being introduced more and more with the special graphics objects which often are almost or nearly completely opaque to the user so they cannot be customized for special purposes. I think this is a misguided direction on Mathworks' part; in this case it's a positive to have introduced more special characters; it's a bad thing to have done so at the expense of removing base functionality so the user doesn't have the choice of using the tool as they would choose, not being limited by what Mathworks thinks are all the possibilities anybody should want.
"I propose the following workarounds to solving your query.
1. For rectangular boxes ...specify the ‘EdgeColor’...
2. For circular boxes ... plot circular markers around the text..."
I would suggest to counter that either
- text() should add the 'shape' parameter to control the box shape; the 'Curvature' property of the rectangle() function would be able to then shape-shift the box from square/rectangular thru any level of rounded corners to the circle. The extent and location are already known, thereby bypassing the issue of the 2nd above. Or,
- annotation(shapeType) should have the 'Text' property added to display the text along with the shape.
Either of those would be a much cleaner solution that given existing functionality, shouldn't be too difficult to implement.
Paul
on 13 Oct 2025
Adding an extra line to the plot just to get the circled text could be problematic, or at least annoying. For example, that additional, single-marker line will have to be dealt with in the legend, any findobj code looking for lines, etc.
Yeah, but one could manage the pain somewhat if wrapped in a user function to set
...
hCirc=plot(x,y,'o','Markeredgecolor',c,'Markersize',sz,'HandleVisibility','off');
hCirc.Annotation.LegendInformation.IconDisplayStyle='off;
Accepted Answer
More Answers (1)
Walter Roberson
on 13 Oct 2025
0 votes
\raisebox and \fbox were never previously documented as working.
I speculate that when Mathworks converted java based figures to javascript based figures, that they had to re-implement latex, and that they simply did not take the time to re-implement commands that were previously supported but were undocumented.
3 Comments
dpb
on 13 Oct 2025
Prior releases never documented anything about what was/wasn't supported w/ LaTeX; they just had a few minimal examples and the pretty-much useless
"For more information about the LaTeX system, see The LaTeX Project website at https://www.latex-project.org/". Finding out how to create an effect from there is not going to happen directly.
About the only luck I ever had was doing a google search to find an implementation of a desired effect and then trial and error to see if, by any chance, the various possibilites were supported in the MATLAB incaranation. This is through R2022b, anyways; I presume this also stayed the same until R2025a although with the slow connection I've not yet gone beyond to R2023/24.
I can see why Mathworks would want to restrict what users can do with LaTeX; in general it wasn't really intended for the purpose outside document preparation with the full environment.
Hmmm...I had never tried with the older releases, but I don't suppose one could write a preample and create definitions as a compound text string and then pass that to the interpreter. Without know just what is and isn't there, it's just a trial and error exercise so from that standpoint at least with the new documentation one can find out what you can and can't do; one will simply have to accept and be satisfied with what Mathworks decides you need. Of course, one can always still submit enhancement requests, but they're not likely to get much traction if more than just an additional symbol or the like I'd guess going forward.
Walter Roberson
on 13 Oct 2025
https://www.mathworks.com/help/releases/R2024b/matlab/matlab_prog/insert-equations.html?s_tid=doc_srchtitle#bvak56c-1 lists Supported LaTeX commands.
OK, so that is, I presume also when it became a subtopic in the Live Editor documentation instead of standing alone as annotation of graphics.
However, note for text for use as @Gokhan Pekcan is/was using the interpreter the documentation is still identical as it was before in R2022b and text is still the same documentation links as it was before as well. No indication anything changed there with the use of 'Interpreter','latex' from prior releases.
From this it appears Mathworks has switched horses in midstream with only live scripts having been considered in revising LaTeX support. And, you'll never stumble across the above list from the text function documentation.
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!