我正在尝试将联系信息插入到页面(文章类)的左上角和标题上方。这是我的示例代码。
\documentclass[a4paper,oneside,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr, graphicx}
\usepackage{geometry}
\geometry{a4paper,top=3cm,bottom=3cm,left=1.5cm,right=1.5cm,heightrounded,bindingoffset=5mm,headheight=5cm, voffset=1cm}
\usepackage[english]{babel}
\begin{document}
\fancyhead[R]{\includegraphics[width=4cm]{Images/logo.png}}
\pagestyle{plain}
\vspace{9cm}
\title{\textbf{Title}}
\maketitle
\thispagestyle{fancy}
Bla bla bla.
\end{document}
这就是我想要实现的目标:
谢谢大家的帮助!
答案1
\@maketitle
通过包修改命令的可能解决方案etoolbox
:
\documentclass[a4paper,oneside,12pt,notitlepage]{article}
\usepackage[utf8]{inputenc}
\usepackage[draft]{graphicx}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{geometry}
\geometry{a4paper,top=3cm,bottom=3cm,left=1.5cm,right=1.5cm,heightrounded,bindingoffset=5mm,headheight=5cm, voffset=1cm}
\usepackage[english]{babel}
\fancyhead[R]{\includegraphics[width=4cm]{Images/logo.png}}
\newcommand{\contactinfo}{%
\noindent
Contact informations:\\
Lorem ipsum 345-443-2342\\
[email protected]\\
tel. 345/1234567}
\title{The Title}
\author{Lorem Ipsum}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@maketitle}
{\vskip 2em}
{\vskip-1cm{\raggedright\contactinfo\vspace{1cm}}}
{}
{}
\makeatother
\begin{document}
\maketitle
\thispagestyle{fancy}
\lipsum
\end{document}
如果没有etoolbox
你需要这个:
\makeatletter
\def\@maketitle{%
\newpage
\null
\vskip-1cm
{\raggedright\contactinfo}
\vspace{1cm}
\begin{center}%
\let \footnote \thanks
{\LARGE \@title \par}%
\vskip 1.5em%
{\large
\lineskip .5em%
\begin{tabular}[t]{c}%
\@author
\end{tabular}\par}%
\vskip 1em%
{\large \@date}%
\end{center}%
\par
\vskip 1.5em}
\makeatother
答案2
使用 tikz 的解决方案。您可以根据需要调整长度。
\documentclass[a4paper,oneside,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr, graphicx}
\usepackage{geometry}
\geometry{a4paper,top=3cm,bottom=3cm,left=1.5cm,right=1.5cm,heightrounded,bindingoffset=5mm,headheight=5cm, voffset=1cm}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\begin{document}
\fancyhead[R]{\includegraphics[height=1cm]{example-image-a}}
\pagestyle{plain}
% \vspace{9cm}
\title{\textbf{Title}}
\maketitle
\begin{tikzpicture}[overlay, remember picture, outer sep=0pt, inner sep=1ex]
\node [draw, thick, anchor=north west] at ($(current page.north)-(.5*\textwidth-1ex, \headheight)$){\parbox{3cm}{Nom:\\ Prénom:\\Mél:}};
\end{tikzpicture}
\thispagestyle{fancy}
Bla bla bla.
\end{document}