How to format a LaTeX string in python?

后端 未结 2 1092
南笙
南笙 2021-02-06 00:46

I\'m writing an application, part of whose functionality is to generate LaTeX CVs, so I find myself in a situation where I have strings like

\\begin{document}
\\         


        
2条回答
  •  迷失自我
    2021-02-06 00:58

    Why won't this work?

    >>> output = r'\author{{email}}'.format(email='user@example.org')
    >>> print output
    \author{email}
    

    edit: Use double curly braces to "escape" literal curly braces that only LaTeX understands:

    >>> output = r'\begin{{document}} ... \author{{{email}}}'.format(
    ... email='user@example.org')
    >>> print output
    \begin{document} ... \author{user@example.org}
    

提交回复
热议问题