Converts italic fonts LaTeX subscripts 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)) \\frac{V_{\\
(textext)
| 865 | return Snippet(TEX, self.format) |
| 866 | |
| 867 | def sub2rm(textext): |
| 868 | """ |
| 869 | Converts italic fonts LaTeX subscripts into mathrm fonts. |
| 870 | |
| 871 | :param textext: LaTeX snippet |
| 872 | :type textxt: str |
| 873 | |
| 874 | :return: Modified LaTeX snippet |
| 875 | :rtype: str |
| 876 | |
| 877 | :example: |
| 878 | |
| 879 | >>> textext = "\\frac{V_{out}}{V_{in}}" |
| 880 | >>> print(sub2rm(textext)) |
| 881 | \\frac{V_{\\mathrm{out}}}{V_{\\mathrm{in}}} |
| 882 | """ |
| 883 | pos = 0 |
| 884 | out = '' |
| 885 | pattern = re.compile(r'_{([a-zA-Z0-9]+)}') |
| 886 | for m in re.finditer(pattern, textext): |
| 887 | out += textext[pos:m.start()+1]+'{\\mathrm'+textext[m.start()+1: m.end()]+'}' |
| 888 | pos = m.end() |
| 889 | out += textext[pos:] |
| 890 | return out |
| 891 | |
| 892 | # Non-public functions for creating table snippets |
| 893 |