模拟 moderncv 的“\cventry”而不使用此类

模拟 moderncv 的“\cventry”而不使用此类

有没有办法\cventry{}{}{}{}{}{}在不使用该moderncv包的情况下在纯 LaTeX 中获得效果?

是否存在一个\newcommand补丁\cventry,当在任何标准 TeX 文件中初始化时可以重现这种效果moderncv

答案1

好吧,你可以自己做这个,只需稍微尝试一下,像这样:

  1. 将命令的定义复制\cventry到序言中的其他类中,并\cventry在文档中使用命令。
  2. 编译并查看结果错误:command \cvitem is undefined
  3. 将命令的定义复制\cvitem到序言中。不要忘记添加所需的包(calcxcolorifthen)...
  4. 编译并查看结果错误:缺少更多定义。
  5. 将缺失的定义复制到前言中并再次编译。
  6. 如果您得到了所有缺失的定义,则代码现在就可以编译。

article请参阅以下类和命令的示例\cventry

\documentclass{article}

\usepackage{calc}   % <=================================================
\usepackage{xcolor} % <=================================================
\usepackage{ifthen} % <=================================================

% <================== added code from moderncv.cls and moderncvbodyi.sty
\newcommand*{\cventry}[7][.25em]{%
  \cvitem[#1]{#2}{%
    {\bfseries#3}%
    \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}%
    \ifthenelse{\equal{#5}{}}{}{, #5}%
    \ifthenelse{\equal{#6}{}}{}{, #6}%
    .\strut%
    \ifx&#7&%
    \else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}\fi}}

\newcommand*{\cvitem}[3][.25em]{%
  \begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
    \raggedleft\hintstyle{#2} &{#3}%
  \end{tabular}%
  \par\addvspace{#1}}

\newlength{\hintscolumnwidth}
\setlength{\hintscolumnwidth}{0.175\textwidth}

\newlength{\separatorcolumnwidth}
\setlength{\separatorcolumnwidth}{0.025\textwidth}

\newlength{\maincolumnwidth}
\setlength{\maincolumnwidth}{\textwidth-\leftskip-\rightskip-\separatorcolumnwidth-\hintscolumnwidth}

\definecolor{color0}{rgb}{0,0,100} % <================================== blue
\newcommand*{\hintfont}{\mdseries} % <================================== bold
\newcommand*{\hintstyle}[1]{{\hintfont\textcolor{color0}{#1}}}


\begin{document}

\section{Test}

This is a usual paragraph in the document. This is a usual paragraph in the document. 
This is a usual paragraph in the document. This is a usual paragraph in the document. 
This is a usual paragraph in the document. This is a usual paragraph in the document. 

\section{Education}
\cventry{year--year}{Degree}{really very long Institution--3}{very long City--4}{\textit{Grade}--5}%
  {This is a very long description--6. This is a very long description. 
   This is a very long description. This is a very long description. 
   This is a very long description. This is a very long description}  

\end{document}

并查看其生成的 pdf 页面:

生成的 pdf

相关内容