2

I am using the package moderncv. I implemented already a conditional statement in the preamble:

\usepackage{ifthen}
\newif\ifresume
\resumetrue %true for RESUME, false for CV

This allows me to set up different designs for either generation of a resume or a cv based on the same data. What I would like to do now, is to also to implement this condition in the

\cventry{year--year}{Degree}{Institution}{City}{Grade}{Description}

data fields in the following sense:

\cventry{year--year}{Degree}{Institution}{City}{Grade}{(short) Description for resume}{(long) Description for CV}

I already tried various ideas to implement this, but none succeeded. The obvious solution would be

\cventry{year--year}{Degree}{Institution}{City}{Grade}{\ifresume
%Text for RESUME
\else
%Text for CV
\fi}

but that does not appear very pracicable.#

Any ideas how to solve this smoothly?

Cheers, Mil

4
  • 1
    Have you considered using a combination of xparse and expl3? That would allow you a very simple document-level interface with very readable code-behind. (If you go this route, I'd also recommend using l3keys, but that's my preference… something like cvtext= and resumetext=.) Jan 31, 2014 at 15:17
  • I havn't heard about these packages before and am not completely sure what their result would be. I will look into them though. :)
    – Mil
    Jan 31, 2014 at 15:20
  • 2
    Make a \newcommand that incorporates \cventry into it with 7 args.; when \resumetrue is in effect, it spits out all 7, when \resumefalse is in effect, it spits out 6. Note that the ifthen package is not needed for \newif, and also is superseded in many ways by etoolbox.
    – jon
    Jan 31, 2014 at 15:20
  • I had the same idea at the same moment! :)
    – Mil
    Jan 31, 2014 at 15:21

2 Answers 2

3

Consider using a combination of expl3 and xparse:

output

Note that, since it's keyval-based markup, you can explicitly set resume-mode for any single item (or group of items, if you do { \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}
7
  • That looks like a very promising solution Seal Allred! Its very elegant! Just a short question: I am trying to change my layout settings in dependence on \ResumeMode[false] or \ResumeMode[true], however I am not sure how to adjust the if-command: \ifResumeMode %settings for resume \else %settings for cv \fi. Do you know what the proper command is? :)
    – Mil
    Feb 1, 2014 at 15:40
  • 1
    @Mil Take a look at the \bool_if:NTF macro there -- it takes a look at \_mil_resume_mode_bool and inserts resumetext or cvtext depending. Take a look at page 38 of texdoc interface3 for a more detailed explanation, but the syntax idea is basically \if{resume mode}{true code}{false code}. That is, \bool_if:NTF \l_resume_mode_bool {true code}{false code} or \bool_if:NT \l_resume_mode_bool {true code} or \bool_if:NF \l_resume_mode_bool {false code}. Feb 1, 2014 at 15:53
  • Ah, that clears things up, thank you. I thought I understood how it works, but the implementation still doesnt work. I tried \moderncvcolor{\bool_if:NTF \l_mil_resume_mode_bool {blue}{green}} and \bool_if:NTF \l_mil_resume_mode_bool {\moderncvcolor{blue}}{\moderncvcolor{green}} but I only get "undefined control sequence.
    – Mil
    Feb 1, 2014 at 16:09
  • @Mil What is it saying is undefined? (My gut tells me to try \exp_args:No \moderncvcolor { \bool_if:NTF ... }) Feb 1, 2014 at 16:43
  • I think your gut was right: It doesnt give any errors now. However it only works for the "true" code. ResumeMode[false] gives the same result as ResumeMode[true].
    – Mil
    Feb 1, 2014 at 16:52
1

The following code gives me a solution. But it is still not very nice:

\newcommand{\Cventry}[7]{\ifresume \cventry{#1}{#2}{#3}{#4}{#5}{#6} \else \cventry{#1}{#2}{#3}{#4}{#5}{#7} \fi}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .