我需要在第一页中添加不同的页眉和页脚内容。我可以使用什么包来完成这个过程。
\documentclass[twocolumn, 9pt, a4paper]{extarticle}
\usepackage{titlesec}
\titlelabel{\thetitle.\quad}
\usepackage{pbox}
\usepackage{hyperref}
\usepackage[includefoot, footskip=0.4in]{geometry}
\geometry{a4paper, left=0.6in, right=0.4in, top=0.8in, bottom=0.5in}
\usepackage{array, booktabs}
\usepackage{threeparttable}[caption]
\usepackage[utf8x]{inputenc}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage[format=plain, justification=justified, singlelinecheck=true, font={small}, labelfont=bf,labelsep=period]{caption}
\usepackage[figurename=Fig.]{caption}
\setlength\captionmargin{15pt}
\usepackage{etoolbox}
\newlength\newtop
\setlength{\newtop}{0.4in}
\makeatletter
\patchcmd\@outputpage{\global \@colht \textheight}{%
\global\textheight=\dimexpr\textheight+\newtop\relax%
\global\topmargin=\dimexpr\topmargin-\newtop\relax%
\global\@colht\textheight%
\global\newtop\z@}{}{\err}
\makeatother
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{setspace}
\usepackage{anyfontsize}
\usepackage{siunitx}
\usepackage{afterpage, fancyhdr, xpatch}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{widetext}
\usepackage{ragged2e}
\setlength{\belowcaptionskip}{-0.5pt}
\setlist[itemize]{noitemsep}
\setlength{\intextsep}{5pt plus 1.0pt minus 2.0pt}
\setlength{\headheight}{15.6pt}
\setlength{\headsep}{6pt}
\renewcommand{\footrulewidth}{0.5pt}
\begin{document}
\pagestyle{fancy}
\thispagestyle{plain}
\fancypagestyle{plain}{
\fancyhead[L]{\hspace{-0.1cm}\vspace{-0.4cm}\includegraphics[height=50pt]{Header1}}
\fancyhead[R]{\hspace{0cm}\vspace{0.1cm}\includegraphics[height=0.35in]{Image1}\\\includegraphics[width=9.5cm]{Image}}
}
\pagestyle{fancy}
\afterpage{\fancyhead[R]{\includegraphics[width=2.5cm]{Header2}}}
{\fancyhead[L]{xxxxx.,}}
{\fancyfoot{}
\fancyfoot[L]{ \includegraphics[width=0.5in]{Image1}}
\fancyfoot[C]{\hspace{0.5cm} \textbf{\textit{\small xxxxxx}}}
\fancyfoot[R]{\thepage}}
\section{Introduction}
A basic paragraph structure usually consists of five sentences: the topic sentence, three supporting sentences, and a concluding sentence. But the secrets to paragraph writing lay in four essential elements, which when used correctly, can make a okay paragraph into a great paragraph.
\end{document}
答案1
首先,您的 MWE 有很多可能不需要的东西。尝试使其更具体化。关于您的问题 - 您不需要花这么长时间。有更简单的方法可以做到这一点。fancyhdr
软件包包括以下命令 -
lhead
,,,,,chead
lhead
rfoot
cfoot
lfoot
惯例是将这些命令写在序言中,但您也可以将它们写在文档之间。
我为不同页面的不同页眉和页脚准备了一个示例。
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lipsum}
\parindent=0pt
\begin{document}
\thispagestyle{fancy}
\pagenumbering{gobble} %This command will disable pagecounting.
\cfoot{First page}
\lipsum
\pagenumbering{arabic} %From this pagecounting will start.
\cfoot{\thepage} %This will disable the effect of your first \cfoot command.
\lipsum
\end{document}
此代码将生成以下输出 -
答案2
除了 fancyhdr 之外,您还可以使用标题
\documentclass{article}
\usepackage{titleps}
\usepackage{lipsum}
% syntax
\newpagestyle{myfirstpage}[]{ %between [] after the pagestyle name you can insert \scshape for example {as long as you have a font that supports small caps!}
\sethead[〈even-left〉][〈even-center〉][〈even-right〉]
{〈odd-left〉}{〈odd-center〉}{〈odd-right〉}
\setfoot[〈even-left〉][〈even-center〉][〈even-right〉]
{〈odd-left〉}{〈odd-center〉} {〈odd-right〉}
}
% then you create a 2th pagestyle with the same syntax code above but with different name and your personal options!
\begin{document}
\pagestytle{myfirstpage}
Bla Bla bla
\newpage
\pagestyle{different name}
Bla Bla
\end{document}