我承认,我是个初学者,所以我请求您帮助我为标题页添加页眉。我想在标题页上放置一张图片作为页眉,在其他页面上放置另一个页眉和页脚。目前,我设置的页眉和页脚可以正常工作,但我不知道如何为标题页设置页眉和页脚。我该怎么做?以下是代码
\documentclass{article}
\usepackage[italian]{babel}
\usepackage[paper=a4paper, top=3cm, bottom=2.5cm, left=2.5cm, right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{float}
\usepackage{afterpage}
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{wrapfig}
\usepackage{lastpage}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{\includegraphics[width=2cm]{logo.png}}
\fancyfoot[R]{Page \thepage~of \pageref{LastPage}}
\fancyfoot[L]{John Doe}
\fancyfoot[C]{E1A}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\newcommand\blankpage{
\null
\thispagestyle{empty}
\addtocounter{page}{-1}
\newpage
}
\begin{document}
\begin{titlepage}
\fancyhead{\lhead{\includegraphics[width=2cm]{logo.png}}}
\begin{center}
\vspace*{3cm}
\rule{\textwidth}{1.6pt}\vspace*{-\baselineskip}\vspace*{3.5pt}
\rule{\textwidth}{0.4pt}
\vspace{2\baselineskip}
{\Huge Electric and hybrid,\\the future\\}
\vspace{2\baselineskip}
\rule{\textwidth}{0.4pt}\vspace*{-\baselineskip}\vspace{3.5pt}
\rule{\textwidth}{1.6pt}
\vspace{2\baselineskip}
\vspace{2\baselineskip}
{\LARGE John Doe \\}
\vspace{0.5\baselineskip}
\end{center}
\begin{large}
\end{titlepage}
\end{document}
答案1
\documentclass{article}
\usepackage[italian]{babel}
\usepackage[paper=a4paper, top=4cm, bottom=2.5cm, left=2.5cm, right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{float}
\usepackage{afterpage}
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{wrapfig}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\pagestyle{fancy}
\newcommand{\headerpic}[1]{%
\begin{tikzpicture}[remember picture,overlay]
\node [anchor=south west,inner sep=0] at (current page header area.north west)
{\includegraphics[height=2cm]{#1}};
\end{tikzpicture}
}
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{\headerpic{example-image-b}}
\fancyfoot[R]{Page \thepage~of \pageref{LastPage}}
\fancyfoot[L]{John Doe}
\fancyfoot[C]{E1A}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\newcommand\blankpage{
\null
\thispagestyle{empty}
\addtocounter{page}{-1}
\newpage
}
\begin{document}
\begin{titlepage}
\headerpic{example-image-a}
\begin{center}
\vspace*{3cm}
\rule{\textwidth}{1.6pt}\vspace*{-\baselineskip}\vspace*{3.5pt}
\rule{\textwidth}{0.4pt}
\vspace{2\baselineskip}
{\Huge Electric and hybrid,\\the future\\}
\vspace{2\baselineskip}
\rule{\textwidth}{0.4pt}\vspace*{-\baselineskip}\vspace{3.5pt}
\rule{\textwidth}{1.6pt}
\vspace{2\baselineskip}
\vspace{2\baselineskip}
{\LARGE John Doe \\}
\vspace{0.5\baselineskip}
\end{center}
%\begin{large}
\end{titlepage}
\lipsum[1-8]
\lipsum[1-8]
\end{document}