我想修改以下程式碼,以便在頁眉中添加徽標,在頁腳中添加一些文字。那可能嗎?
\documentclass[a4paper, 10pt]{article} % for A4 size paper
\usepackage{tikz}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[remember picture, overlay]
\tikzset{normal lines/.style={gray, very thin}}
\tikzset{margin lines/.style={gray, thick}}
\tikzset{mm lines/.style={gray, ultra thin}}
\tikzset{strong lines/.style={black, very thin}}
\tikzset{master lines/.style={black, very thick}}
\tikzset{dashed master lines/.style={loosely dashed, black, very thick}}
\node at ([xshift=1cm, yshift=8.5mm] current page.south west){
\begin{tikzpicture}[remember picture, overlay]
\draw[style=mm lines,step=1mm] (0,0) grid +(19cm,28cm);
\draw[style=strong lines,step=1cm] (0,0) grid +(19cm,28cm);
\end{tikzpicture}
};
\end{tikzpicture}
\end{document}
答案1
由於您已經在使用,因此這裡有一個使用該節點(您已經在使用)tikz
的簡單解決方案。current page
我還稍微簡化了你的程式碼。我希望這就是您正在尋找的。
\documentclass[a4paper, 10pt]{article} % for A4 size paper
\usepackage{graphicx}
\usepackage{mwe}
\usepackage{tikz}
\tikzset{
normal lines/.style={gray, very thin},
margin lines/.style={gray, thick},
mm lines/.style={gray, ultra thin},
strong lines/.style={black, very thin},
master lines/.style={black, very thick},
dashed master lines/.style={loosely dashed, black, very thick}
}
\begin{document}
\pagestyle{empty}
\tikz [remember picture, overlay]
\node at (current page.center) {
\begin{tikzpicture}
\draw[style=mm lines,step=1mm] (0,0) grid +(19cm,28cm);
\draw[style=strong lines,step=1cm] (0,0) grid +(19cm,28cm);
\end{tikzpicture}
};
\tikz [remember picture, overlay]
\node [anchor=north] at (current page.north) {\includegraphics[height=0.6cm]{example-image-a}};
\tikz [remember picture, overlay]
\node [anchor=south] at (current page.south) {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent viverra turpis ac semper auctor.};
\end{document}
輸出:
附錄
您在標題中引用了 PDF 的第一頁。我猜您希望在每一頁上列印這張方格紙,但只有第一頁有徽標和文字?您可以使用以下方法輕鬆建立更多具有網格的頁面:
\foreach \i in {1, 2, ..., 49} {
\clearpage
\tikz [remember picture, overlay]
\node at (current page.center) {
\begin{tikzpicture}
\draw[style=mm lines,step=1mm] (0,0) grid +(19cm,28cm);
\draw[style=strong lines,step=1cm] (0,0) grid +(19cm,28cm);
\end{tikzpicture}
};
}
可以\end{document}
在上面的範例之前添加。這將產生 50 頁方格紙,其中第一頁僅包含徽標和文字。