小编Dan*_*iel的帖子

在 Python 3 中格式化 LaTeX 数学字符串

我认为有可能通过使用一个双花括号如图所示使用的格式方法上的乳胶串在python这里。例如:

In[1]: 'f_{{{0}}}'.format('in')
Out[1]: 'f_{in}'
Run Code Online (Sandbox Code Playgroud)

但是如何在数学 LaTeX 字符串中使用 format 方法?(特别是下标)

例如,与:

In[2]: r'$f_{in,{{0}}}$'.format('a')
Run Code Online (Sandbox Code Playgroud)

我希望:

Out[2]: '$f_{in,a}$'
Run Code Online (Sandbox Code Playgroud)

但我得到一个

ValueError: unexpected '{' in field name
Run Code Online (Sandbox Code Playgroud)

string math latex python-3.x

6
推荐指数
1
解决办法
4546
查看次数

标签 统计

latex ×1

math ×1

python-3.x ×1

string ×1