jam*_*mes 2 python latex pylatex
如果我有一个使用 pylatex 设置的简单文档...
import pylatex as pl
geometry_options = {
"head": "1pt",
"margin": "0.2in",
"bottom": "0.2in",
"includeheadfoot": False}
doc = pl.Document(geometry_options=geometry_options)
doc.append("text")
Run Code Online (Sandbox Code Playgroud)
...如何在文本块后添加一定粗细的黑色水平分隔线?
在问同样的事情时发现了您未回答的问题。从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.")
Run Code Online (Sandbox Code Playgroud)
我仍在研究 LaTeX,所以我确信有一种比强制NewLine()
那样更清洁的方法,但这是使其正确间隔的唯一方法。