定义新的 tblr 环境导致错位对齐错误

定义新的 tblr 环境导致错位对齐错误

awesome-cv通过使用以下内容修改类,我cvskills使用tabularray包重新定义环境

\NewEnviron{cvskills}{%
  \begin{tblr}[expand=\BODY]{
    colspec={Q X},
  }
    \BODY
  \end{tblr}
}

% Define a line of cv information(skill)
% Usage: \cvskill{<type>}{<skillset>}
\newcommand*{\cvskill}[2]{%
    \skilltypestyle{#1} & \skillsetstyle{#2} \\
}

然而,当使用它时,它应该导致Misplaced alignment tab character &. \cvskill #1#2->\skilltypestyle {#1} &

\begin{cvskills}

  \cvskill{Programming}{Skill1, Skill2, Skill3}
  
\end{cvskills}

cvskills当像在普通表中一样插入值时,环境会起作用

\begin{cvskills}

  Programming & Skill1, Skill2, Skill3 \\
  
\end{cvskills}

答案1

您想使用\NewDocumentEnvironment并扩展\cvskills

在下面的例子中,我使用未修改的awesome-cvand do \RenewDocumentEnvironmentand \renewcommand

\documentclass[]{awesome-cv}
\usepackage{tabularray}

\RenewDocumentEnvironment{cvskills}{+b}{%
  \begin{tblr}[expand=\cvskill]{
    colspec={Q X},
  }
    #1
  \end{tblr}
}{}

% Define a line of cv information(skill)
% Usage: \cvskill{<type>}{<skillset>}
\renewcommand*{\cvskill}[2]{%
    \skilltypestyle{#1} & \skillsetstyle{#2} \\
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     Personal Data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Essentials
\name{Some}{Name}
\address{An Address, 3245}
\mobile{(+57) 45-45654-434} 
%%% Social
\email{[email protected]}
\homepage{www.SomePage.com}
\github{Someone2}
\linkedin{Someone2}
%%% Optionals
\position{My Position}
\quote{``I am me.''}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     Content
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Make a footer for CV with three arguments(<left>, <center>, <right>)
\makecvfooter
  {\today}
  {My Resume}
  {\thepage}

\begin{document}
%%% Make a header for CV with personal data
\makecvheader

\begin{cvskills}
  \cvskill{Programming}{Skill1, Skill2, Skill3}
\end{cvskills}

\end{document}

在此处输入图片描述

相关内容