MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / sub2rm

Function sub2rm

docs/sphinx_report.py:115–139  ·  view source on GitHub ↗

Converts LaTeX subscripts in italic fonts into mathrm fonts. :param textext: LaTeX snippet :type textxt: str :return: Modified LaTeX snippet :rtype: str :example: >>> textext = "\\frac{V_{out}}{V_{in}}" >>> print(sub2rm(textext)) \\fr

(textext)

Source from the content-addressed store, hash-verified

113# Work-around to change subscripts to mathrm:
114
115def sub2rm(textext):
116 """
117 Converts LaTeX subscripts in italic fonts into mathrm fonts.
118
119 :param textext: LaTeX snippet
120 :type textxt: str
121
122 :return: Modified LaTeX snippet
123 :rtype: str
124
125 :example:
126
127 >>> textext = "\\frac{V_{out}}{V_{in}}"
128 >>> print(sub2rm(textext))
129
130 \\frac{V_{\\mathrm{out}}}{V_{\\mathrm{in}}}
131 """
132 pos = 0
133 out = ''
134 pattern = re.compile(r'_{([a-zA-Z0-9]+)}')
135 for m in re.finditer(pattern, textext):
136 out += textext[pos:m.start()+1]+'{\\mathrm'+textext[m.start()+1: m.end()]+'}'
137 pos = m.end()
138 out += textext[pos:]
139 return out
140
141# Convert all the snippets
142

Callers 1

sphinx_report.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected