我想在位置 (x,y) 居中对齐添加章节名称,以及页码和日期。但是代码有什么问题?如果我得到这个,我该如何添加日期(每个章节)并将其移动到位置 (x,y)?
这是我的 MWE:
\documentclass[12pt,oneside]{book}
\usepackage{background}
\usepackage{lipsum}
\usetikzlibrary{calc}
\backgroundsetup{
angle=0,
scale=1,
opacity=1,
color=black,
contents={%
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=center,inner sep=0pt] at ($(current page.north west) + (16.3cm,-1.8cm)$) {\thepage};
\node[anchor=center,inner sep=0pt] at ($(current page.north) + (20cm,-5cm)$) {\thechapter};
\end{tikzpicture}%
}
}
%\usepackage[step=0.5cm,arrows=false,firstcolor=white,secondcolor=white]{pagegrid} %% comment this
%\pagegridsetup{top-left} %% comment this
\begin{document}
\thispagestyle{empty} %% this is needed
\chapter*{Hello World}
\lipsum[4-10]
\end{document}
答案1
你可以把所有的东西都放进去而tikzpicture
不用使用\chapter*{..}
\documentclass[12pt,oneside]{book}
\usepackage{background}
\usepackage{lipsum}
\usetikzlibrary{calc}
\backgroundsetup{
angle=0,
scale=1,
opacity=1,
color=black,
contents={%
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=center,inner sep=0pt] at ($(current page.north west) + (16.3cm,-1.8cm)$) {\thepage};
\end{tikzpicture}%
}
}
%\usepackage[step=0.5cm,arrows=false,firstcolor=white,secondcolor=white]{pagegrid} %% comment this
%\pagegridsetup{top-left} %% comment this
\begin{document}
\addtocounter{chapter}{1} %% do this at the start of each expt
\pagestyle{empty} %% this is needed
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=center,inner sep=0pt,font=\Large\bfseries] at ($(current page.north west) + (3.8cm,-2.7cm)$) {Expt \thechapter};
\node[anchor=center,inner sep=0pt,font=\Large\bfseries] at ($(current page.north) + (0cm,-2.7cm)$) {Hello World};
\node[anchor=center,inner sep=0pt] at ($(current page.north west) + (16.5cm,-2.7cm)$) {5.04.2014};
\end{tikzpicture}%
\lipsum[4-10]
\end{document}