title: Format a LaTeX math string in Python 3
body: <p>I see it is possible to use the format method on a LaTeX string in python by using a double curly bracket as shown <a href="https://stackoverflow.com/questions/6672213/how-to-format-a-latex-string-in-python#6672249">here</a>. For instance:</p>
  
  <pre><code>In[1]: 'f_{{{0}}}'.format('in')
  Out[1]: 'f_{in}'
  </code></pre>
  
  <p>But how can I use the format method in a math LaTeX string? (particularly for subscripts)</p>
  
  <p>For example, with:</p>
  
  <pre><code>In[2]: r'$f_{in,{{0}}}$'.format('a')
  </code></pre>
  
  <p>I would expect:</p>
  
  <pre><code>Out[2]: '$f_{in,a}$'
  </code></pre>
  
  <p>But I get a</p>
  
  <pre><code>ValueError: unexpected '{' in field name
  </code></pre>