I got most of the following code from here: Generating pdf-latex with python script
#!/usr/bin/env python
from __future__ import division
from functions import *
import shlex
#from Utilities import *
import os
import argparse
import subprocess
equation = '\begin{equation*}1 + \gamma\lambda B/2\end{equation*}'
content=r'''\documentclass{article}
\usepackage{graphicx,amsmath}
\begin{document}
\noindent\rotatebox{180}{\vbox{%
%(equation)s
}%
}
\end{document}
'''
parser=argparse.ArgumentParser()
parser.add_argument('-e', '--equation', default=equation)
args=parser.parse_args()
content%args.__dict__
print content%args.__dict__
running this code gives me the following error:
Traceback (most recent call last):
File "latex.py", line 29, in <module>
content%args.__dict__
ValueError: unsupported format character '
' (0xa) at index 104
anybody know what's going wrong? I've got the same error from other methods of rotating the page.
Any %
in content
is seen as a formatting placeholder. Double any that are not a placeholder:
content=r'''\documentclass{article}
\usepackage{graphicx,amsmath}
\begin{document}
\noindent\rotatebox{180}{\vbox{%%
%(equation)s
}%%
}
\end{document}
'''
Otherwise the %
at the end of the \noindent\rotatebox{180}{\vbox{%
line is seen together with the \n
newline as a formatting character, hence the exception with an embedded newline.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With