Found your unanswered question while asking the same thing. Harvesting from Gonzalo Medina's answer on a post for the TeX StackExchange, you could incorporate this using NoEscape
. There's other examples you can use and you'll just need to insert them into the raw string (r""
).
import pylatex as pl
from pylatex.utils import NoEscape
from pylatex.basic import NewLine
geometry_options = {
"head": "1pt",
"margin": "0.2in",
"bottom": "0.2in",
"includeheadfoot": False}
doc = pl.Document(geometry_options=geometry_options)
doc.append("text")
doc.append(NewLine())
doc.append(NoEscape(r"\noindent\rule{\textwidth}{1pt}"))
doc.append(NewLine())
doc.append("Text under the rule.")
I'm still figuring out LaTeX so I am sure there's a cleaner way than forcing a NewLine()
like that, but it was the only way to have it spaced correctly.