我想在文档的右上方(水平线上方)添加一个图像。另外,我想将章节标题(显示在文档的左边距)格式化为红色。
\documentclass[10pt]{article}
\usepackage{calc}
\usepackage{comment}
\usepackage{soul}
\makeatletter
\newlength{\bibhang}
\setlength{\bibhang}{1em} %1em}
\newlength{\bibsep}
{\@listi \global\bibsep\itemsep \global\advance\bibsep by\parsep}
\newenvironment{bibsection}%
{\begin{enumerate}{}{%
\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibsep}%
\setlength{\parsep}{\z@}%
\setlength{\partopsep}{0pt}%
\setlength{\topsep}{0pt}}}
{\end{enumerate}\vspace{-.6\baselineskip}}
\makeatother
\reversemarginpar
\usepackage{titlesec}
\usepackage[paper=letterpaper,
%includefoot, % Uncomment to put page number above margin
marginparwidth=1.2in, % Length of section titles
marginparsep=.05in, % Space between titles and text
margin=1in, % 1 inch margins
includemp]{geometry}
\setlength{\parindent}{0in}
\usepackage[shortlabels]{enumitem}
\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\fancyhf{}\renewcommand{\headrulewidth}{0pt}
\fancyfootoffset{\marginparsep+\marginparwidth}
\newlength{\footpageshift}
\setlength{\footpageshift}
{0.5\textwidth+0.5\marginparsep+0.5\marginparwidth-2in}
\lfoot{\hspace{\footpageshift}%
\parbox{4in}{\, \hfill %
\arabic{page} of \protect\pageref*{LastPage} % +LP
\hfill \,}}
\usepackage{color,hyperref}
\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\hypersetup{colorlinks,breaklinks,
linkcolor=darkblue,urlcolor=darkblue,
anchorcolor=darkblue,citecolor=darkblue}
\newcommand{\makeheading}[2][]%
{\hspace*{-\marginparsep minus \marginparwidth}%
\begin{minipage}[t]{\textwidth+\marginparwidth+\marginparsep}%
{\large \bfseries #2 \hfill #1}\\[-0.15\baselineskip]%
\rule{\columnwidth}{1pt}%
\end{minipage}}
\renewcommand{\section}[1]{\pagebreak[3]%
\hyphenpenalty=10000%
\vspace{1.3\baselineskip}%
\phantomsection\addcontentsline{toc}{section}{#1}%
\noindent\llap{\scshape\smash{\parbox[t]{\marginparwidth}{\raggedright #1}}}%
\vspace{-\baselineskip}\par}
\newenvironment{outerlist}[1][\enskip\textbullet]%
{\begin{itemize}[#1,leftmargin=*]}{\end{itemize}%
\vspace{-.6\baselineskip}}
\newenvironment{lonelist}[1][\enskip\textbullet]%
{\begin{list}{#1}{%
\setlength{\partopsep}{0pt}%
\setlength{\topsep}{0pt}}}
{\end{list}\vspace{-.6\baselineskip}}
\newenvironment{innerlist}[1][\enskip\textbullet]%
{\begin{itemize}[#1,leftmargin=*,parsep=0pt,itemsep=0pt,topsep=0pt,partopsep=0pt]}
{\end{itemize}}
\newenvironment{loneinnerlist}[1][\enskip\textbullet]%
{\begin{itemize}[#1,leftmargin=*,parsep=0pt,itemsep=0pt,topsep=0pt,partopsep=0pt]}
{\end{itemize}\vspace{-.6\baselineskip}}
\newcommand{\blankline}{\quad\pagebreak[3]}
\newcommand{\halfblankline}{\quad\vspace{-0.5\baselineskip}\pagebreak[3]}
\newcommand\doilink[1]{\href{http://dx.doi.org/#1}{#1}}
\newcommand\doi[1]{doi:\doilink{#1}}
\providecommand*\url[1]{\href{#1}{#1}}
\renewcommand*\url[1]{\href{#1}{\texttt{#1}}}
\providecommand*\email[1]{\href{mailto:#1}{#1}}
\providecommand\BibTeX{{B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
\TeX}}
\providecommand\Matlab{\textsc{Matlab}}
\begin{document}
\makeheading{Abhimanyu Arora}
\section{Contact Information}
\newlength{\rcollength}\setlength{\rcollength}{2in}
\begin{tabular}[t]{@{}p{\textwidth-\rcollength}p{\rcollength}}
Off no. 123 & 123 456 789 \\
Belgium & \email{[email protected]}\\
\end{tabular}
\section{Research Interests}
Development Economics, Microeconomics
\section{Education}
\textbf{University of Belgium},
\begin{outerlist}
\item[] Ph.D. Student, {Economics}
\begin{innerlist}
\item Thesis Topic: \emph{Essays in Development Economics}
\end{innerlist}
\end{outerlist}
\end{document}
我尝试了命令
\makeheading[\includegraphics[height=1.5in]{my_picutre}]{Your Name}
我刚才有\makeheading
,但没成功。错误消息说找不到行尾...
答案1
无需讨论模板,您可以通过以下方式实现您的目标:
- 添加照片:
\makeheading[{\includegraphics[width=1.5cm]{photo}}]{Abhimanyu Arora}
更改部分的样式:
\renewcommand{\section}[1]{\pagebreak[3]% \hyphenpenalty=10000% \vspace{1.3\baselineskip}% \phantomsection\addcontentsline{toc}{section}{#1}% \noindent\llap{\scshape\smash{\parbox[t]{\marginparwidth}{\raggedright\textcolor{red}{#1}}}}% \vspace{-\baselineskip}\par}
以下是完整的 MWE 及其结果:
\documentclass[10pt]{article}
\usepackage{graphicx}
\usepackage{calc}
\usepackage{comment}
\usepackage{soul}
\makeatletter
\newlength{\bibhang}
\setlength{\bibhang}{1em} %1em}
\newlength{\bibsep}
{\@listi \global\bibsep\itemsep \global\advance\bibsep by\parsep}
\newenvironment{bibsection}%
{\begin{enumerate}{}{%
\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibsep}%
\setlength{\parsep}{\z@}%
\setlength{\partopsep}{0pt}%
\setlength{\topsep}{0pt}}}
{\end{enumerate}\vspace{-.6\baselineskip}}
\makeatother
\reversemarginpar
\usepackage{titlesec}
\usepackage[paper=letterpaper,
%includefoot, % Uncomment to put page number above margin
marginparwidth=1.2in, % Length of section titles
marginparsep=.05in, % Space between titles and text
margin=1in, % 1 inch margins
includemp]{geometry}
\setlength{\parindent}{0in}
\usepackage[shortlabels]{enumitem}
\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\fancyhf{}\renewcommand{\headrulewidth}{0pt}
\fancyfootoffset{\marginparsep+\marginparwidth}
\newlength{\footpageshift}
\setlength{\footpageshift}
{0.5\textwidth+0.5\marginparsep+0.5\marginparwidth-2in}
\lfoot{\hspace{\footpageshift}%
\parbox{4in}{\, \hfill %
\arabic{page} of \protect\pageref*{LastPage} % +LP
\hfill \,}}
\usepackage{color,hyperref}
\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\hypersetup{colorlinks,breaklinks,
linkcolor=darkblue,urlcolor=darkblue,
anchorcolor=darkblue,citecolor=darkblue}
\newcommand{\makeheading}[2][]%
{\hspace*{-\marginparsep minus \marginparwidth}%
\begin{minipage}[t]{\textwidth+\marginparwidth+\marginparsep}%
{\large \bfseries #2 \hfill #1}\\[-0.15\baselineskip]%
\rule{\columnwidth}{1pt}%
\end{minipage}}
\renewcommand{\section}[1]{\pagebreak[3]%
\hyphenpenalty=10000%
\vspace{1.3\baselineskip}%
\phantomsection\addcontentsline{toc}{section}{#1}%
\noindent\llap{\scshape\smash{\parbox[t]{\marginparwidth}{\raggedright\textcolor{red}{#1}}}}%
\vspace{-\baselineskip}\par}
\newenvironment{outerlist}[1][\enskip\textbullet]%
{\begin{itemize}[#1,leftmargin=*]}{\end{itemize}%
\vspace{-.6\baselineskip}}
\newenvironment{lonelist}[1][\enskip\textbullet]%
{\begin{list}{#1}{%
\setlength{\partopsep}{0pt}%
\setlength{\topsep}{0pt}}}
{\end{list}\vspace{-.6\baselineskip}}
\newenvironment{innerlist}[1][\enskip\textbullet]%
{\begin{itemize}[#1,leftmargin=*,parsep=0pt,itemsep=0pt,topsep=0pt,partopsep=0pt]}
{\end{itemize}}
\newenvironment{loneinnerlist}[1][\enskip\textbullet]%
{\begin{itemize}[#1,leftmargin=*,parsep=0pt,itemsep=0pt,topsep=0pt,partopsep=0pt]}
{\end{itemize}\vspace{-.6\baselineskip}}
\newcommand{\blankline}{\quad\pagebreak[3]}
\newcommand{\halfblankline}{\quad\vspace{-0.5\baselineskip}\pagebreak[3]}
\newcommand\doilink[1]{\href{http://dx.doi.org/#1}{#1}}
\newcommand\doi[1]{doi:\doilink{#1}}
\providecommand*\url[1]{\href{#1}{#1}}
\renewcommand*\url[1]{\href{#1}{\texttt{#1}}}
\providecommand*\email[1]{\href{mailto:#1}{#1}}
\providecommand\BibTeX{{B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
\TeX}}
\providecommand\Matlab{\textsc{Matlab}}
\begin{document}
\makeheading[{\includegraphics[width=1.5cm]{photo}}]{Abhimanyu Arora}
\section{Contact Information}
\newlength{\rcollength}\setlength{\rcollength}{2in}
\begin{tabular}[t]{@{}p{\textwidth-\rcollength}p{\rcollength}}
Off no. 123 & 123 456 789 \\
Belgium & \email{[email protected]}\\
\end{tabular}
\section{Research Interests}
Development Economics, Microeconomics
\section{Education}
\textbf{University of Belgium},
\begin{outerlist}
\item[] Ph.D. Student, {Economics}
\begin{innerlist}
\item Thesis Topic: \emph{Essays in Development Economics}
\end{innerlist}
\end{outerlist}
\end{document}