我正在使用 moderncv 包。我在序言中已经实现了一个条件语句:
\usepackage{ifthen}
\newif\ifresume
\resumetrue %true for RESUME, false for CV
这样我就可以根据相同的数据设置不同的设计,以生成简历或简历。我现在想做的是,在
\cventry{year--year}{Degree}{Institution}{City}{Grade}{Description}
数据字段的含义如下:
\cventry{year--year}{Degree}{Institution}{City}{Grade}{(short) Description for resume}{(long) Description for CV}
我已经尝试了各种方法来实现这一点,但都没有成功。显而易见的解决方案是
\cventry{year--year}{Degree}{Institution}{City}{Grade}{\ifresume
%Text for RESUME
\else
%Text for CV
\fi}
但这似乎不太可行。#
有什么想法可以顺利解决这个问题吗?
干杯,米尔
答案1
expl3
考虑使用和的组合xparse
:
请注意,由于它是基于 keyval 的标记,因此您可以resume-mode
为任何单个项目(或项目组,如果您这样做的话{ \ResumeMode[true] \CVEntry{…} \CVEntry{…} … }
)明确设置。
\documentclass{moderncv}
\usepackage{expl3,xparse}
\ExplSyntaxOn
\keys_define:nn { mil / resume } { % from `expl3`
start .tl_set:N = \l_mil_resume_start_tl,
end .tl_set:N = \l_mil_resume_end_tl,
degree .tl_set:N = \l_mil_resume_degree_tl,
institution .tl_set:N = \l_mil_resume_institution_tl,
city .tl_set:N = \l_mil_resume_city_tl,
grade .tl_set:N = \l_mil_resume_grade_tl,
resume-text .tl_set:N = \l_mil_resume_resumetext_tl,
cv-text .tl_set:N = \l_mil_resume_cvtext_tl,
resume-mode .bool_set:N = \l_mil_resume_mode_bool
}
\NewDocumentCommand \ResumeMode { O{true} } { % from `xparse`
\keys_set:nn { mil / resume } { resume-mode = #1 }
}
\NewDocumentCommand \CVEntry { m } {
\group_begin:
\keys_set:nn { mil / resume } { #1 }
\cventry{\l_mil_resume_start_tl--\l_mil_resume_end_tl}
{\l_mil_resume_degree_tl}
{\l_mil_resume_institution_tl}
{\l_mil_resume_city_tl}
{\l_mil_resume_grade_tl}
{
\bool_if:NTF \l_mil_resume_mode_bool {
\l_mil_resume_resumetext_tl
} {
\l_mil_resume_cvtext_tl
}
}
\group_end:
}
\ExplSyntaxOff
\moderncvstyle{oldstyle}
\name{John}{Doe}
\ResumeMode[false]
\begin{document}
\CVEntry{
start=1993,
end=2005,
degree=B.\,S.,
institution=\TeX\ StackExchange,
city=Internet,
grade=Grade,
resume-text=resume text,
cv-text=cv text,
}
\CVEntry{
start=1993,
end=2005,
degree=B.\,S.,
institution=\TeX\ StackExchange,
city=Internet,
grade=Grade,
resume-text=resume text,
cv-text=cv text,
resume-mode=true,
}
\end{document}
答案2
以下代码给了我一个解决方案。但它仍然不是很好:
\newcommand{\Cventry}[7]{\ifresume \cventry{#1}{#2}{#3}{#4}{#5}{#6} \else \cventry{#1}{#2}{#3}{#4}{#5}{#7} \fi}