标题页垂直居中
我正在尝试使用乳胶将标题垂直居中在自定义尺寸的页面上。我编写了以下代码,但由于某种原因它没有居中。有人可以指出我有什么问题吗?
谢谢!
\documentclass{article}
\setlength{\pdfpagewidth}{88.184mm}
\setlength{\pdfpageheight}{113.854mm}
\usepackage[margin=0.5cm, paperwidth=88.184mm, paperheight=113.854mm]{geometry}
\title{[[title]]}
\date{[[date]]}
\author{[[author]]}
\begin{document}
\vspace{\fill}
\maketitle
\vspace{\fill}
\newpage
[[text]]
\end{document}
I'm trying to vertically center a title on a custom-sized page with latex. I've written the following code, but for some reason it doesn't center. Could someone please point me to what's wrong with it?
Thanks!
\documentclass{article}
\setlength{\pdfpagewidth}{88.184mm}
\setlength{\pdfpageheight}{113.854mm}
\usepackage[margin=0.5cm, paperwidth=88.184mm, paperheight=113.854mm]{geometry}
\title{[[title]]}
\date{[[date]]}
\author{[[author]]}
\begin{document}
\vspace{\fill}
\maketitle
\vspace{\fill}
\newpage
[[text]]
\end{document}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的代码中有两个小错误。
首先,如果您希望
\vspace
在页面的开头或结尾工作,则应使用带星号的版本 (\vspace*
)。这可行,但是
\maketitle
是一个非常复杂的宏,如果像您的示例中那样使用,它只会将标题放在第二页上。您可以使用titlepage
环境,它使您可以更好地控制标题页的外观 - 包括间距。例如,您可以使用以下代码:There are two small bugs in your code.
First, if you want the
\vspace
to work at the beginning or end of a page, you should use the starred version (\vspace*
).This would work, but
\maketitle
is a pretty complicated macro, and if used like in your example, it just puts the title at the second page. You can use thetitlepage
environment, which gives you much more command over how the title page looks like -- including the spacing. For example, you could use the following code:如果您想让一切正常工作,即使使用
\maketitle
也可以将\vspace*{\fill}
放在第一个和最后一个属性 exp 中:If you want to make everything work even with
\maketitle
put your\vspace*{\fill}
inside the first and the last attribute, exp:正如 finrod 的回答所示,
\maketitle
是一个非常复杂的宏,这就是为什么我不想自己覆盖它(\renewcommand\maketitle{
...)。尽管如此,复制、粘贴和编辑 article.cls documentclass,我可以添加一个新的文档类来自定义 (\newcommand\mymaketitle{
...),如下所示:输出:
As in the answer by finrod,
\maketitle
is a pretty complicated macro, this is why I didn't feel like overwriting it myself (\renewcommand\maketitle{
...). Nevertheless, copying, pasting and editing lines 170-201 of article.cls documentclass, I could add a new one to customize (\newcommand\mymaketitle{
...) as follows:The output: