在问同样的事情时发现了你未回答的问题。从Gonzalo Medina在 TeX StackExchange 的帖子中的回答中收获,您可以使用NoEscape
. 您还可以使用其他示例,只需将它们插入原始字符串 ( 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.")
我仍在研究 LaTeX,所以我确信有一种比强制NewLine()
这样更清洁的方法,但这是让它正确间隔的唯一方法。