我正在用 LaTeX 创建简历。以下代码是 MWE(example.tex):
%%% ------------------------------------------------------------
\documentclass[paper=letterpaper,fontsize=10pt]{article} % KOMA-article class
\usepackage{amsmath,amsfonts,amsthm} % Math packages
\usepackage{graphicx} % Enable pdflatex (had [pdftex])
\usepackage[svgnames]{xcolor} % Colors by their 'svgnames'
\usepackage{geometry}
% \textheight=700px % Saving trees ;-)
\usepackage{url} % Clickable URL's
\usepackage{wrapfig} % Wrap text along figures
\frenchspacing % Better looking spacings after periods
\pagestyle{empty} % No pagenumbers/headers/footers
%%%%%%%%%%%%%%%%%%%%%%% FOR ICONS %%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fontawesome}
\usepackage{fontspec} %Github, mail, etc icons
\newfontfamily{\FA}[Path = fonts/]{fontawesome-webfont}
\def\faLinux{{\FA\symbol{"F17C}}}
\def\faSE{{\FA\symbol{"F18D}}}
\def\faSkype{{\FA\symbol{"F17E}}}
\def\github{{\FA\symbol{"F092}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Custom sectioning (sectsty package)
\usepackage{sectsty} % Custom sectioning (see below)
\sectionfont{% % Change font of \section command
\usefont{OT1}{phv}{b}{n}% % bch-b-n: CharterBT-Bold font
\sectionrule{0pt}{0pt}{-5pt}{3pt}
}
%%% Macros
\newlength{\spacebox}
\settowidth{\spacebox}{8888888888} % Box to align text
\newcommand{\sepspace}{\vspace*{1em}} % Vertical space macro
\newcommand{\NewPart}[1]{\section*{\uppercase{#1}}}
\newcommand{\EdEntry}[4]{
\noindent \textbf{#1} \hfill % Study
\colorbox{Black}{%
\parbox{6em}{%
\hfill\color{White}#2}} \par % Duration
\textit{#3} \par % School
\normalsize \par}
\newcommand{\ResearchEntry}[4]{
\noindent \textbf{#1} \hfill % Study
\colorbox{Black}{%
\parbox{6em}{%
\hfill\color{White}#2}} \par % Duration
\noindent \textit{#3} \par % School
\noindent \small #4 % Description
\normalsize \par}
%%% BEGIN DOCUMENT ------------------------------------------------------------
\begin{document}
\noindent \colorbox{Black}{\parbox{4em} \hfill \color{White} \Huge \usefont{OT1}{phv}{b}{n} FIRST NAME}
\newline
\noindent \colorbox{Black}{\parbox{4em} \hfill \color{White} \Huge \usefont{OT1}{phv}{b}{n} LAST NAME}
%%%%%%%%%%%%%%%%%%%%%%% FOR ICONS %%%%%%%%%%%%%%%%%%%%%%%%%
Linux icon: \faLinux \\
StackExchange icon: \faSE \\
GitHub icon: \github \\
Skype icon: \faSkype
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Education ------------------------------------------------------------
\NewPart{Education}{}
\EdEntry{Ph.D. \hspace{1mm} Major: Major Name}{Then-Now}{\hspace{11.5mm} School Name}
\EdEntry{B.S. \hspace{4mm} Major: Major Name}{Then1-Then2}{\hspace{13.5mm} School Name}
%%% Research Experience --------------------------------------------------
\NewPart{Experience}{}
\ResearchEntry{Job Title I}{Time I}{Place I}{Here I am describing my experience}
\ResearchEntry{Job Title II}{Time II}{Place II}{I will describe my experience here}
%%% References ------------------------------------------------------------
\NewPart{References}{}
Available upon request
\end{document}
只要注释掉两行代码块(15-21 和 63-66),就可以使用“pdflatex example.tex”生成 CV。在上面的例子中,这些代码块被注释符号包围,注释符号为“FOR ICONS”。
我正在尝试向我的 CV(GitHub、Skype 等)添加一些符号。这些符号来自 FontAwesome 包。与添加这些符号相关的所有代码都在前面提到的两个行块中。因此,这两个行块导致了问题。
当我尝试运行“xelatex example.tex”时,出现错误:
(/usr/local/texlive/2014/texmf-dist/tex/latex/fontspec/fontspec.sty
! Undefined control sequence.
l.1 {\rtf
1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf210
当我查看我的 fontspec.sty 脚本(位于 /usr/local/texlive/2014/texmf-dist/tex/latex/fontspec/)时,我发现未定义的控制序列是第一行。
我应该说,我通过复制粘贴此链接中的所有内容来创建 fontspec.sty 文件(http://chocolatshalba.ch/files/texlive/texmf-dist/tex/latex/fontspec/fontspec.sty) 转换为文本文件,并将其作为 .sty 保存到上面显示的目录中。
我已经研究这个问题几个小时了,但还是不知所措。你可能知道我不太熟悉 .sty 文件的工作原理!谢谢你的任何建议;这可能会帮助我找到工作!...
答案1
fontawesome
这实际上并不是对您问题的直接回答,但您可以使用正在加载的包直接访问 FontAwesome 的图标。只是宏名称有部分不同。
%%%%%%%%%%%%%%%%%%%%%%% FOR ICONS %%%%%%%%%%%%%%%%%%%%%%%%%
Linux icon: \faLinux \\
StackExchange icon: \faStackExchange \\
GitHub icon: \faGithub \\
Skype icon: \faSkype
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
通过 fontspec 手动加载字体并创建宏是多余的。因此,只需删除第 16-21 行,使用正确的宏名称即可。