有什么办法可以添加一些文字身体(而不是页眉或页脚)在每一页上都显示,就像直接输入一样?
我想做如下事情:
- 按正常方式输入正文;
This is line 1.
\par
This is line 2.
声明要添加的一些文本。例如,“
[Inserted text]\
”。然后,在每一个新页面上,TeX 程序都会将正文视为如下内容:
[Inserted text]\
This is line 1.
\par
This is line 2.
- 这样输出就是这个样子:
((Indent))[Inserted text] This is line 1.((Line Break))
((Indent))This is line 2.
这是我为实现此目标所做的事情。所有尝试都失败了。(请不要介意图像的不同宽度)
首先,我尝试定义\@texttop
命令;
\makeatletter
\newcommand{\@texttop}{[Inserted text]\ }
\makeatother
输出如下:
其次,我尝试使用阿特别格什包裹;
\usepackage{atbegshi}
\AtBeginShipout{%
\AtBeginShipoutAddToBox{[Inserted text]\ }%
}
输出如下:
第三,我尝试修补\@outputpage
命令:
\makeatletter
\AtBeginDocument{%
\let\x@@outputpage@orig\@outputpage
\renewcommand{\@outputpage}{%
\let\x@@begindvi@orig\@begindvi
\renewcommand{\@begindvi}{%
\x@@begindvi@orig
\setbox\@outputbox\vbox{%
[Inserted text]\
\unvbox\@outputbox
}%
}%
\x@@outputpage@orig
}%
}%
\makeatother
输出如下:
但是,我实际上想要的是这样的:
有什么方法可以实现吗?
以下是一个示例文档:
\documentclass{minimal}
\usepackage{ifthen}
% 1. Define \@texttop Command
% \makeatletter
% \newcommand{\@texttop}{[Inserted text]\ }
% \makeatother
% 2. Use atbegshi Package
% \usepackage{atbegshi}
% \AtBeginShipout{%
% \AtBeginShipoutAddToBox{[Inserted text]\ }%
% }
% 3. Patch in \@outputpage Command
% \makeatletter
% \AtBeginDocument{%
% \let\x@@outputpage@orig\@outputpage
% \renewcommand{\@outputpage}{%
% \let\x@@begindvi@orig\@begindvi
% \renewcommand{\@begindvi}{%
% \x@@begindvi@orig
% \setbox\@outputbox\vbox{%
% [Inserted text]\
% \unvbox\@outputbox
% }%
% }%
% \x@@outputpage@orig
% }%
% }%
% \makeatother
\title{How to Add/Insert Some Text to Body at Every New Page, As If It Was Input Directly}
\author{\texttt{cmplstofB}}
\begin{document}
% What I Want Actually
% [Inserted text]\
\newcounter{tmpcntx}%
\setcounter{tmpcntx}{1}%
\whiledo{\value{tmpcntx}<90}{%
This is line \arabic{tmpcntx}.
\par
\stepcounter{tmpcntx}%
}%
\newpage
And, here is new page.
\newpage
[Inserted text]\ Acctually, I want a output like this.
\end{document}