How do I get bold formatted subscript mathematical expressions in MATLAB using LaTeX?

I want to format the variable as given as an axis label for a figure using the the latex interpreter: Both, g and R, should be italic, but R should be subscript and bold additionally. In the corresponding document, that the figure is for, I formatted it as $g_{\boldsymbol{R}}$, however this does not seem to work here. So far, I found a very similar question, yet the accepted answer does not use a subscript and I do not seem to get the described math mode switching to work. Any help, getting the math mode switching to work, or a totally different approach to format the label as intended, is appreciated. Thanks in advance!

Answers (2)

x = 0:10;
y = x;
plot(x,y)
xlabel('$g_{\mathbf{\mathit{R}}}$','interpreter','latex')

3 Comments

Here, the R is upright, but it should be italic.
Now, the R is italic, but not bold anymore, in R2022a at least. The commands for formatting characters bold and italic show the same behavior of deactivating each other, that I faced before posting the question.

Sign in to comment.

Using
g_{\it\textbf{R}}
works here using tthe LaTeX interpreter (Σ button in the top toolbar) --
The 'R' actually is subscripted. Were it not, it would appear as --
Using it as an axis label --
figure
xlabel('$g_{\it\textbf{R}}$', Interpreter='LaTeX')
.

4 Comments

Here, the R is upright, but it should be italic, in R2022a at least. The commands for formatting characters bold and italic show the same behavior of deactivating each other, that I faced before posting the question.
It works correctly in R2024b (apparently the online Run application has not upgraded to R2025a yet) --
figure
xlabel('$g_{\it\textbf{R}}$', Interpreter='LaTeX', FontSize=26)
Here, the 'R' is bold, italic, and subscripted. (The code is the same as before, with only the FontSize name-value pair added for clarity.
If it is not working this way in your R2022a installation, be sure you have downloaded and insatalled all the updates. If this was a bug, it could have been fixed.
.
I updated it, yet, the issue still occurs. Could you think of a workaround or have a look at how to adapt this approach? I do not really want to change the version of my installation for this project.
If the approach that you reference works for you, then go for it. It appears to work, at least in the referenced releases.
Alternatively, you can plot here and then upload the plot as an image --
figure
xlabel('$g_{\it\textbf{R}}$', Interpreter='LaTeX', FontSize=26)
savefig(gcf,'ItalicBoldSubscript.fig')
figfiles = dir('*.fig')
figfiles = struct with fields:
name: 'ItalicBoldSubscript.fig' folder: '/users/mss.system.pzgkb' date: '20-Aug-2025 16:59:44' bytes: 5901 isdir: 0 datenum: 7.3985e+05
which('ItalicBoldSubscript.fig')
/users/mss.system.pzgkb/ItalicBoldSubscript.fig
openfig('ItalicBoldSubscript');
There does not appear to be a way to save it to MATLAB Drive (at lest that I can find, if that were possible you could then export it through MATLAB Online), so the easiest way to do it would probably be to copy it by right-clicking on it and then saving it appropriately, or taking a screenshot of it.
.

Sign in to comment.

Products

Release

R2022a

Asked:

on 20 Aug 2025

Commented:

on 20 Aug 2025

Community Treasure Hunt

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

Start Hunting!