What works in 2024 stopped with 2025: Latex interpreter

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?
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:
dpb
dpb on 13 Oct 2025
Edited: dpb on 13 Oct 2025
"...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.
I believe the circled text can be adjusted to look more visually pleasing (as I referenced in my original questions, and you refered to as well). Nonetheless, the response from MathWorks does not really address the issue... it simply proposes an alternative solution (see below), which should work, though with some effort to center and fit text inside the marker. I’m not sure why I didn’t think of this myself... still hopeful :)
GP--
begin --- MathWorks Technical Support.
I propose the following workarounds to solving your query.
1. For rectangular boxes, you can simply specify the ‘EdgeColor’ and you can see a box of that color around the text. Example; text(0.5,0.5,’My Text Box’,’EdgeColor’,’k’);
2. For circular boxes, you can plot circular markers around the text. Example: text(0.5,0.5,'2'); plot(0.5,0.5,'o','Markeredgecolor','r','Markersize',20);
This will draw a circle of red color around the text ‘2’. Note that you might have to play around with the ‘markersize’ property based on your screen size or size of the figure window. Also, slight tweaks to positions might be needed.
For the code snippet you shared, the workaround looks as follows:
hold on;
text(0.5,0.5,[' ' num2str(14) ' :i-end'],...
'HorizontalAlignment','left','VerticalAlignment', 'bottom', 'Color','m',...
'Interpreter','latex',"FontSize",14); % (remove normalised units)
plot(0.52,0.53,'mo','MarkerSize',20);%for circular box (note the positioning and size)
text(0.2,0.5,num2str(25),...
'HorizontalAlignment','center','VerticalAlignment', 'top','rotation',40,...
'Interpreter','latex',"FontSize",11,'EdgeColor','r'); % note the edgecolor parameter
I hope this answers your query.
Feel free to reach out again if you have any follow-up questions or comments regarding this issue.
Thanks,
[... snip ...]
MathWorks Support.
end --- MathWorks Technical Support.
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.
dpb
dpb on 13 Oct 2025
Edited: dpb on 13 Oct 2025
"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
  1. 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,
  2. 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.
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;

Sign in to comment.

 Accepted Answer

dpb
dpb on 12 Oct 2025
Edited: dpb on 13 Oct 2025
Submit this to Mathworks as an official support request/bug at <Product Support Page>.
With the new nendering engine much seems to be different and/or broken, but Mathworks won't know about rare usage issues unless they're reported.
ADDENDUM
As in Comment above, it appears Mathworks has purposely removed these builtin LaTeX commands in latest release. IMO, that is misguided on their part; let the user decide whether the result is ok or not, don't prevent the use entirely, whether it is an elegant solution or not.
I've not seen much noise in the area recently, a number of years ago there was quite a bit of activity trying to add packages, but it appears folks just gave up as a lost cause. That again, would seem to me to be a reasonable enhancement request to document how that can be done or add the ability if not presently so...or use another full implementation instead.

More Answers (1)

\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

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.
dpb
dpb on 13 Oct 2025
Edited: dpb on 14 Oct 2025
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.

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Release

R2025b

Asked:

on 12 Oct 2025

Edited:

dpb
on 14 Oct 2025

Community Treasure Hunt

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

Start Hunting!