我想在每页的开头插入一些内容(我的情况是表格)。此外,我想在文档中设置两个“标记”,以便只在标记之间的每页开头打印这些内容(特别是,我希望能够在第一页上省略这些内容)。
以下是一些可能有效的伪代码:
\documentclass{article}
\usepackage{tabularray}
\usepackage{geometry}
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[R]{\small Header}
\fancyfoot[C]{\small Header}
\fancyhead[L]{\small Header}
\pagestyle{fancy}
\usepackage{lipsum}
%\AtBeginDocument{
\AtEveryPageFromMarkerAtoB{
\begin{center}
\begin{tblr}{hlines,vlines,width=\linewidth,colspec={XXX}}
A table & containing & some stuff \\
large enough & not to fit & into \\
a header & & \\
\end{tblr}
\end{center}
}
\begin{document}
%% On the first page the header should be ommitted, or more general it should start on the page with marker A
\lipsum
\markerA
\newpage
%% From here on, the table should be inserted automatically to the beginning of every page
\lipsum
\newpage
\lipsum
%% From now on the table should be ommited.
\markerB
\lipsum
\newpage
\lipsum
\end{document}
并不是说我只包含了\newpage
创建示例的明确命令。无论我明确插入新页面还是自动生成,它都应该有效
答案1
您可以使用钩子:
\documentclass{article}
\usepackage{tabularray}
\usepackage{geometry}
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[R]{\small Header}
\fancyfoot[C]{\small Header}
\fancyhead[L]{\small Header}
\pagestyle{fancy}
\usepackage{lipsum}
\begin{document}
%% On the first page the header should be ommitted, or more general it should start on the page with marker A
\lipsum
\AddToHook{shipout/before}[foo]{
\begin{center}
\begin{tblr}{hlines,vlines,width=\linewidth,colspec={XXX}}
A table & containing & some stuff \\
large enough & not to fit & into \\
a header & & \\
\end{tblr}
\end{center}
}
\newpage
%% From here on, the table should be inserted automatically to the beginning of every page
\lipsum
\newpage
\lipsum
\RemoveFromHook{shipout/before}[foo]
\lipsum
\newpage
\lipsum
\end{document}