使用以下 TikZ 代码或背景图像,我想向其中添加一些信息并将其用作我的标题页,以便它完美适合 A4 纸张大小。
\begin{tikzpicture}
\shadedraw [left color=red,right color=blue] (0,0) rectangle (10,13);
\end{tikzpicture}
我想补充一点:
- 我的书名位于顶部中央:“这是我的书名”,白色文字。
- 然后,在其下方是作者,也位于中心,并且为白色:“作者 XY”。我使用的是标准书籍类别。
- 最后,下面的日期也以白色居中显示。
我怎样才能实现这个目标?
提前致谢。
答案1
您不必用 来做所有事情tikz
。事实上,这样做并不可取。用 绘制阴影区域,tikz
使用 环境 键入其他所有内容titlepage
。这样您可以更好地控制。
\documentclass{book}
\usepackage{tikz}
\usepackage[a4paper,margin=1in]{geometry}
\begin{document}
\begin{titlepage}
\centering \sffamily
\begin{tikzpicture}[remember picture,overlay]
\shade [top color=red,bottom color=blue] (current page.south west) rectangle (current page.north east);
\end{tikzpicture}
{\Huge\textcolor{white}{This is my book'stitle}}
\par\vspace{0.5in}
{\large \textcolor{white}{This is my subtitle}}
\par\vspace{\stretch{1}}
{\Large \textcolor{white}{Author XY}}
\par
\vfill
\textcolor{white}{\today}
\end{titlepage}
\end{document}
答案2
这会是您想要的吗?这里有一个解决方案,分别在current page.south west
和处定义节点 A 和 B。current page.north east
将这三行分别写在处current page.north, current page.center and current page.south
。实际上,当前页面节点概念是绝对位置,可以添加选项[xshift=<dim>,yshift=<dim>]
以将节点放置在页面中的任何位置并写入文本。例如,
\node [yshift=-3cm,text=white] at (current page.north){\large \sf This is a subtitle};
将在书名下方添加副标题。
代码
\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
\pagestyle{empty} % \pagestyle command corrected
\begin{tikzpicture}[remember picture,overlay]
\node (A) at (current page.south west){};
\node (B) at (current page.north east){};
\shade [top color=red,bottom color=blue] (A) rectangle (B);
\node [yshift=-2cm,text=white] at (current page.north){\Huge \sf This is my book'stitle};
\node [yshift=-3cm,text=white] at (current page.north){\large \sf This is a subtitle};
\node [text=white] at (current page.center){\Large \sf Author XY};
\node [yshift=2cm,text=white] at (current page.south){\today};
\end{tikzpicture}
\end{document}