我使用PyLaTeX作为生成pdfs的一种方式(作为烧瓶web应用程序的一部分),而且除了默认的名称和作者之外,我无法让标题和作者保持一定的距离。
到目前为止,我的代码看起来如下(这是折叠日期部分的一种方法)
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}放在author命令中(标题和作者之间的空格保持不变),它似乎什么也不做。另外,把它放在标题中会改变标题上方的空格,而不是下面的标题。
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中正确地使用标题(我昨天学到了大部分这些,所以.)。
发布于 2020-03-15 15:47:20
好吧,就像帕特里克·阿尔纳指出的那样,命令很重要。
doc.preamble.append(Command('title', NoEscape(f"Title with {variable}" + r'\vspace{-1cm}')))从文档中我了解到,\vspace影响了它出现在其中的行(独立于行上放置的位置)。似乎不是这样的(在开头有\vspace会改变标题的高度,但是在标题的末尾改变标题和作者之间的空间)。
https://stackoverflow.com/questions/60691835
复制相似问题