简历中使用的变量的基本定义

简历中使用的变量的基本定义

我正在用 LaTeX 编写简历,希望实现一些命令来自动化章节样式(尽管我绝不打算编写整个类)。例如,我想在序言中包含一些用于联系信息的简单命令,然后我可以使用这些命令来构建页眉。理想情况下它看起来像这样(我已将其包含resume_config.tex在本文底部):

% =============================================================================
%                                   Preamble
% =============================================================================
% Checks for correct LaTeX usage (no out of data packages, poor syntax etc.)
\RequirePackage[l2tabu,orthodox]{nag}
% -----------------------------------------------------------------------------
\documentclass[letterpaper,11pt]{article}
\input{resume_config.tex}

% =============================================================================
%                                    Inputs
% =============================================================================
\name{C. Gonzalez}
\email{[email protected]}
\address{000 E 0th St, Austin, TX 12345}
\phone{(000)111-2222}

% =============================================================================
%                                     Body
% =============================================================================
\begin{document}
\makeheader
% \input{resume_education.tex}
% \input{resume_publications.tex}
\input{resume_experience.tex}
% \input{resume_coursework.tex}
% \input{resume_technical.tex}
% \input{resume_other.tex}
\end{document}

我一直在研究模板的 .cls 文件(awesome-cv),发现他们似乎使用以下代码实现了这种事情:

% Define writer's address
% Usage: \address{<address>}
\newcommand*{\address}[1]{\def\@address{#1}}

我的问题是,这段代码到底是什么意思? 第一的,从我读过的内容来看,这听起来和\def是同一件事\newcommand*,不是吗? 第二,是\@varname{#1}定义变量的语法,如\@varname = #1?我在 tex.stackexchange 的其他地方读过,但似乎无法弄清楚它到底\@是用来做什么的。 第三,编译器似乎不喜欢我之前使用这些命令\begin{document},但我不确定这是否相关......

综上所述,对于我的使用来说,只需在“输入”部分写入以下内容是否相同?

\def\@name{C. Gonzalez}
\def\@email{[email protected]}
\def\@address{000 E 0th St, Austin, TX 12345}
\def\@phone{(000)111-2222}

恢复配置.tex:

% ----------------------------------------------------------- Load packages ---
% geometry - easier to change margine and page setup
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage{amsfonts,amssymb,amsmath,amsthm}
\usepackage[english]{babel}
\usepackage{booktabs}
\usepackage[usenames,dvipsnames]{color}
% multirow - merge table cells vertically (\multirow{nrows}{width}{content})
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{microtype}
\usepackage{siunitx}
\usepackage[colorlinks=true,linkcolor=blue,citecolor=blue,pdfborder={0 0 0}]{hyperref}
\usepackage{enumitem}
\usepackage{titlesec}

% --------------------------------------------------------- Change commands ---
\renewcommand{\arraystretch}{1.1}


% --------------------------------------------------------- Config booktabs ---
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}


% --------------------------------------------------------- Config titlesec ---
% Used for sections of resume (education, experience etc.)
\titleformat{\section}  % Customise the \section command 
  {\Large\raggedright}  % Make the \section headers large (\Large) and left aligned (\raggedright)
  {}{0em}               % Can be used to give a prefix to all sections, like 'Section ...'
  {}                    % Can be used to insert code before the heading
  [\titlerule]          % Inserts a horizontal line after the heading

% Used for subsections of resume (experience 1, experience 2 etc.)
\titleformat{\subsection}
  {\large\raggedright}
  {}{0em}
  {}


% ------------------------------------------------------------ Add commands ---
% Basic Information    
\newcommand{\name}[1]{\def\@name{#1}}
\newcommand{\address}[1]{\def\@address{#1}}
\newcommand{\email}[1]{\def\@email{#1}}
\newcommand{\phone}[1]{\def\@phone{#1}}

\newcommand{\makeheader}[1]{
  \centerline{\Huge{\name}}} \\
  \centerline{\Large{\address \textperiodcentered \email \textperiodcentered \phone}}
}

% Create a subsection with a date (written so that date will not show in table of contents)
\newcommand{\datedsubsection}[2]{%
  \subsection[#1]{#1 \hfill #2}%
}

相关内容