Error in displaying plot while using LaTeX in plot title

I am having trouble adding LaTeX commands to the plot title. Whenever I include them, the plot does not appear. However, when I donโ€™t add any LaTeX commands, the plot appears as expected. Can you please help me fix this issue?
I have attached the relevant code and the error message that I received.

fig.update_layout(
    title= dict(text = f"Reflectance Spectra for TE and TM Modes<br>$n_1$ = {n1}, $n_2$ = {n2}, Number of Layers = {num_layers}, $\theta$ = {th1}"),
    xaxis_title='Wavelength (nm)',
    yaxis_title='Reflectance (%)',
    hovermode='closest',
    showlegend=True,
    height=500,
    width=800,
            )

Javascript Error: Cannot read properties of undefined (reading 'output')

The plot will appear if I donโ€™t write any latex commands.

title= dict(text = f"Reflectance Spectra for TE and TM Modes<br>n1 = {n1}, n2 = {n2}, Number of Layers = {num_layers}, angle = {th1}"),

I am using the following Jupyter Notebook and Plotly versions:

notebook         : 7.0.8
plotly.__version__
'5.20.0'