0

I'm trying to understand use the below user defined command. Could someone help me understand how the command works? In particular, I am a bit confused on what the [0.25em] does here, what {@{}l} and {l@{}} mean. The latter 2 seems like some kind of alignment but I couldn't seem to find definitive information on this.

Also, what does the if else statement at the end do?

\newcommand*{\customcventry}[7][.25em]{
  \begin{tabular}{@{}l} 
    {\bfseries #4}
  \end{tabular}
  \hfill% move it to the right
  \begin{tabular}{l@{}}
     {\bfseries #5}
  \end{tabular} \\
  \begin{tabular}{@{}l} 
    {\itshape #3}
  \end{tabular}
  \hfill% move it to the right
  \begin{tabular}{l@{}}
     {\itshape #2}
  \end{tabular}
  \ifx&#7&%
  \else{\\%
    \begin{minipage}{\maincolumnwidth}%
      \small#7%
    \end{minipage}}\fi%
  \par\addvspace{#1}}

Here's an example of its usage (actually, I've changed this since I downloaded template, so I'm not sure if this is the original intended usage):

{\customcventry{Adviser:}{Degree Name}{University of Blah}{Expected Graduate date}{}{Concentration: }}

and the corresponding output enter image description here

David
  • 101
  • 1
  • 2
    Welcome! [.25em] means that the command has an optional argument with default value .25em. That is, by default you will have \addvspace{.25em} but if you call \customcventry[.1em] that distance will change to .1em, say. {@{}l} means (basically) "left-aligned column with tight space on the left", and likewise for {l@{}}. (I am not sure I like this command because it introduces stray spaces and so on, but this is just an opinion.) –  May 12 '20 at 23:56
  • Welcome to TeX.SX! Where does this command come from? It might be useful to provide some context. – Vincent May 12 '20 at 23:56
  • @Schrödinger'scat Thanks! Since there are 7 arguments, which argument is the optional one? I assume it's the last one? – David May 12 '20 at 23:59
  • @Vincent It's a CV template that I found on Overleaf. I will see if I can find the template again. One moment. – David May 12 '20 at 23:59
  • 1
    Nope, it is #1, which you pass to the command in square brackets, or just not pass it. –  May 13 '20 at 00:00
  • @Vincent Sorry, I can't seem to find the original template file anymore. – David May 13 '20 at 01:42
  • @Schrödinger'scat Ah okay. Do you know what the if statement is doing? I don't know what the condition x&#7&% means. – David May 13 '20 at 02:01
  • 2
    Would you by any chance have an example of how \customcventry is used? It's much easier to go through the elements of this macro if one can refer to an example of what, say, #3 could be. – Mico May 13 '20 at 02:14
  • 2
    The definition seems to come from here, where you can find an example of how it is used. –  May 13 '20 at 02:18
  • 1
    \customcventry is very similar to \mycv but not identical. BTW, \ifx&#7&% tests whether #7 is empty. When #7 is empty, \ifx sees two &, which are equal, so the test is true (and nothing is done). If the test fails, a minipage with #7 in it will be created. The bottomline is that this is yet another way to customize an entry in the moderncv class, hence the name \customcventry. –  May 13 '20 at 02:30
  • @Mico Yes. I just edited that into the OP. – David May 13 '20 at 02:41
  • @Schrödinger'scat Just to confirm, with my usage {\customcventry{Adviser:}{Degree Name}{University of Blah}{Expected Graduate date}{}{Concentration: }}, the Adviser: argument is the second argument? The first argument, if I choose to use it, has square brackets, []? So for example, I could do {\customcventry[0.1em]{Adviser:}{Degree Name}{University of Blah}{Expected Graduate date}{}{Concentration: }}? – David May 13 '20 at 02:49
  • 4
    Sorry, this is not how this site works. You post some fragments here, ask for explanations, and users like @Mico and myself stop by and give feedback. Then you just modify the question without ever bothering to provide a complete example and/or a self-contained question. Why do we have to find out all these things if you already have a document in which you use the macro? Please post a minimal working example and a self-contained question. –  May 13 '20 at 03:11

0 Answers0