Variables in Latex equation strings


I’d like to know if it’s possible to add variables as part of a string to st.latex as it is possible to do in st.write using ‘format’.

For example, if I have a variable a = 2, then the command st.write(f’variable a = {a}’) or similarly st.write(‘a = {}’.format(a)) will print “a = 2”.

But I can’t seem to make it work in st.latex. The equivalent example would be:
st.latex(r’\text{variable } $a = {a}$’), but in this case the variable a isn’t formatted in.
And if I put st.latex(f’variable a = {a}’) then the variable a is formatted in, but the string before it (‘variable’) is in Latex equation format and not in regular Latex text format, which means it is in italics and without spaces.

So is it possible to use st.latex for a combination of Latex text format and Latex equation format when the equation consists of variables formatted in?