我一直试图(但没有成功)更改我的简历的字体,结果现在命令\section*
失败\header
了(而在我进行最后一次更改之前它们曾经工作正常)。我花了很多时间试图找出为什么这些命令现在会失败,但我没有成功。
考虑以下 MWE:
\documentclass{article}
% FONTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage[]{xcolor}
\RequirePackage{marvosym}
\RequirePackage[quiet]{fontspec}
\RequirePackage{unicode-math}
\setmainfont[Color=textcolor,Path=fonts/lato/,BoldItalicFont=Lato-RegIta,BoldFont=Lato-Reg,ItalicFont=Lato-LigIta]{Lato-Lig}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text,Path=fonts/raleway/]{Raleway-ExtraLight}
\newfontfamily\bodyfont
[BoldFont=fonts/lato/Lato-Bol.ttf,
ItalicFont=fonts/lato/Lato-Reg.ttf,
BoldItalicFont=fonts/lato/Lato-BolIta.ttf]
{fonts/lato/Lato-Reg.ttf}
\newfontfamily\thinfont
[BoldFont=fonts/lato/Lato-Bol.ttf,
ItalicFont=fonts/lato/Lato-Reg.ttf,
BoldItalicFont=fonts/lato/Lato-BolIta.ttf]
{fonts/lato/Lato-Reg.ttf}
\newfontfamily\headingfont
[BoldFont=fonts/lato/Lato-Bol.ttf,
ItalicFont=fonts/lato/Lato-Reg.ttf,
BoldItalicFont=fonts/lato/Lato-BolIta.ttf]
{fonts/lato/Lato-Bol.ttf}
\newfontfamily\fontawesome[]{FontAwesome.otf}
\setfontfamily\fontawesome[]{fonts/fontawesome/fontawesome-webfont.ttf}
% HEADER %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{tikz}
\newcommand{\rolefont}{%
\fontsize{14pt}{24pt}\selectfont%
\thinfont%
\color{white}%
}
\newcommand{\header}[2]{%
\begin{tikzpicture}[remember picture,overlay]
\node [rectangle, fill=fillheader, anchor=north, minimum width=\paperwidth, minimum height=5cm,yshift=00.00pt] (box) at (current page.north){};
\node [anchor=center] (name) at (box) {%
\fontsize{40pt}{72pt}\color{black}%
{\bodyfont #1}{\bodyfont #2}
};
\end{tikzpicture}
\vspace{30pt}
}
% STRUCTURE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{parskip}
\renewcommand{\section}[1]{
\par\vspace{\parskip}
{%
\LARGE\headingfont\color{black}%
\@sectioncolor #1%
}
\par\vspace{\parskip}
}
\newcommand{\sectionx}[1]{
{%
\Large\headingfont\color{black}%
\@sectioncolor #1%
}
}
\renewcommand{\subsection}[1]{
\par\vspace{.5\parskip}%
{%
\large\headingfont\color{black} #1%
}
\par\vspace{.25\parskip}%
}
\pagestyle{empty}
% DOCUMENT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\header{Name}{Surname}
\section*{Education}
Hello!
\end{document}
上述 MWE 没有输出任何内容,但会产生大量错误。如果注释掉\header{Name}{Surname}
和行\section*{Education}
,上述 MWE 不会显示任何错误(当然,前提是相应的字体位于指定的文件夹中)。
类似地,如果注释掉行、、\LARGE\headingfont\color{black}%
和,上面的 MWE 不会显示任何错误(再次假设相应的字体位于指定的文件夹中)。\@sectioncolor #1%
\Large\headingfont\color{black}%
\@sectioncolor #1%
\header{Name}{Surname}
另外,我使用的字体可以在这里找到:https://www.overleaf.com/latex/templates/deedy-cv/bjryvfsjdyxz(也可能是在其他地方,但我不知道在哪里)。
有人能帮助我找到并纠正产生这些错误的原因吗?
非常感谢大家抽出时间。
答案1
重要的
不要使用 Overleaf 字体。从以下网站获取具有正确用户许可的字体:
这18个字体文件位于\font\lato
工作目录(Windows OS)的目录中。
的重新定义\section
不包括章节编号。 \section*
没有定义,也没有必要。
fillheader
定义了类似橙色的颜色,并在名字和姓氏之间添加了一个空格。
\documentclass{article}
% FONTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{xcolor}
\definecolor{fillheader}{cmyk}{0,0.5,1,0} % added <<<<<<<<<<<<<
\RequirePackage{marvosym}
\RequirePackage[quiet]{fontspec}
\RequirePackage{unicode-math}
%\setmainfont[Color=textcolor,Path=fonts/lato/,BoldItalicFont=Lato-RegIta,BoldFont=Lato-Reg,ItalicFont=Lato-LigIta]{Lato-Lig}
%
%\setsansfont[Scale=MatchLowercase,Mapping=tex-text,Path=fonts/raleway/]{Raleway-ExtraLight}
\newfontfamily\bodyfont[%% added <<<<<<<<<<<<<
Path=fonts/lato/,
Extension = .ttf,%
UprightFont=*-Regular,%
BoldFont = *-Semibold,%
ItalicFont=*-Italic,%
BoldItalicFont = *-SemiboldItalic,
]{Lato}
\newfontfamily\headingfont[%% added <<<<<<<<<<<<<
Path=fonts/lato/,
Extension = .ttf,%
UprightFont=*-Black,%
BoldFont = *-Bold,%
ItalicFont=*-BlackItalic,%
BoldItalicFont = *-BoldItalic,
]{Lato}
\newfontfamily\thinfont[%% added <<<<<<<<<<<<<
Path=fonts/lato/,
Extension = .ttf,%
UprightFont=*-Light,%
BoldFont = *-Medium,%
ItalicFont=*-LightItalic,%
]{Lato}
% HEADER %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{tikz}
\newcommand{\rolefont}{%
\fontsize{14pt}{24pt}\selectfont%
\thinfont%
\color{white}%
}
\newcommand{\header}[2]{%
\begin{tikzpicture}[remember picture,overlay]
\node [rectangle, fill=fillheader, anchor=north, minimum width=\paperwidth, minimum height=5cm,yshift=00.00pt] (box) at (current page.north){};
\node [anchor=center] (name) at (box) {%
\fontsize{40pt}{72pt}\color{black}%
{\bodyfont #1\enspace}{\bodyfont #2} % changed <<<<<<<<<<<<<<<<
};
\end{tikzpicture}
\vspace{30pt}
}
% STRUCTURE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{parskip}
\renewcommand{\section}[1]{ % stared version not defined
\par\vspace{\parskip}
{%
\LARGE\headingfont\color{black}%
% \@sectioncolor % changed <<<<<<<<<<<<<
#1%
}
\par\vspace{\parskip}
}
\newcommand{\sectionx}[1]{
{%
\Large\headingfont\color{black}%
\@sectioncolor #1% @sectioncolor ?????????????
}
}
\renewcommand{\subsection}[1]{
\par\vspace{.5\parskip}%
{%
\large\headingfont\color{black} #1%
}
\par\vspace{.25\parskip}%
}
\pagestyle{empty}
% DOCUMENT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\header{Name}{Surname}
\section{Education} % changed <<<<<<<<<<<<<
\verb|bodyfont| => {\bodyfont Hello! \textbf{Hello!} \emph{Hello!}}
\verb|headingfont| => {\headingfont Hello! \textbf{Hello!} \emph{Hello!}}
\verb|thinfont| => {\thinfont Hello! \textbf{Hello!} \emph{Hello!}}
\end{document}