我正在使用 PyLaTeX 作为生成 pdf 的一种方式(作为烧瓶网络应用程序的一部分),并且我无法让标题和作者处于默认距离之外的距离。
我的代码现在看起来像这样(这可以作为折叠日期部分的一种方式)
doc.preamble.append(Command('title', f"This is my personalized title with a {variable}"))
doc.preamble.append(Command('author', "This is the author"))
doc.preamble.append(Command('date', NoEscape(r'\vspace{-3ex}'))) #didn't want a date
doc.append(NoEscape(r'\maketitle'))
尝试使用 vspace
问题是,\vspace{-3ex}
如果我将它放在作者命令中(标题和作者之间的空格保持不变),它似乎什么都不做。同样将它放在标题内会更改标题上方的空间,而不是下方。
doc.preamble.append(Command('title', NoEscape(r'\vspace{4.0cm}' + f"Title with {variable}"))) #adds space on top
doc.preamble.append(Command('author', NoEscape(r'\vspace{-3.0cm}' + "Author"))) #this changes nothing
尝试标题
我也尝试过使用titling
LaTeX 包,但我无法从 PyLaTeX 中使用它。我认为它正确地导入了它,但是我不能像其他东西一样更改后缀:
doc.packages.append(Package(titling)) #this seems fine
doc.preamble.append(Command('posttitle','\vspace{-3.0cm}')) #things like this crash the compiler
...
doc.preamble.append(NoEscape(r'\posttittle{\vspace{-3.0cm}}')) #things like this don't work either
虽然我可能没有在 PyLaTeX 中正确使用标题(我昨天学到了大部分内容,所以嗯......)。