fontspec.sty 第一行中未定義的控制序列

fontspec.sty 第一行中未定義的控制序列

我正在用 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”的註釋符號包圍。

我正在嘗試在我的簡歷中添加一些符號(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 行,使用正確的巨集名稱就可以了。

相關內容