2

I'm trying to define two environments, one to be used inside the other. The first is a section in a CV, the second a subsection (cvitem). The latter holds an unordered list (commented for now, to isolate the problem). The subsection should be a two-column, which I'm trying to create using a table, such that all subsections can be aligned together. The cvitem's are then the rows in this table.

\documentclass[12pt]{article}
\usepackage{array}
\usepackage{ragged2e}

\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\newenvironment{cvsection}[1]{
    { \Large \bf #1 }
    \hrule height 0.5pt
    \begin{tabular}{@{}>{}L{.25\linewidth}L{.75\linewidth}@{}}
} {
    \end{tabular}
}

\newenvironment{cvitem}[4]{
    #3 \linebreak #4 & {\bf #1}, #2 \linebreak \\
    %\begin{itemize}
} {
    %\end{itemize}
}

\begin{document}
\begin{cvsection}{Education}
    \begin{cvitem}{xxx}{xx}{xx}{xx}
        %\item x
    \end{cvitem}
\end{cvsection}
\end{document}

When I rewrite the cvitem to a newcommand, the code compiles successfully. But because I want to insert a list, it should be an environment. I tried defining cvitem as a command and converting it to an environment using the environ package, but this resulted in the same errors.

  • 2
    Welcome, i am not a fan of those kinds of definitions for CVs. They are unneeded and just lead to confusion. Where is the code coming from? – Johannes_B Jan 9 at 11:01
  • Except for the column type, I wrote it. Is there another technique you can suggest to achieve the same? – vandenheuvel Jan 9 at 11:24
  • For resumes, i would go for the full brutal method completely by hand -> en.wikibooks.org/wiki/LaTeX/… – Johannes_B Jan 9 at 11:40
  • In this case, that would lead to a lot of duplicate code, though. So you don't know how to resolve this issue I described in the question? – vandenheuvel Jan 9 at 11:53
  • 1
    Aside: Do not use the old TeX font commands but the LaTeX ones (\bfseries) to avoid side effects. – TeXnician Jan 9 at 12:02
1

You cannot issue & in the group formed by the cvitem environment.

With environ and some \aftergroup trickery you can do it.

\documentclass[12pt]{article}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{environ}

\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\newenvironment{cvsection}[1]
 {%
  {\Large\bfseries #1}\vskip3pt\hrule height 0.5pt
  \begin{tabular}{@{}>{}L{.25\linewidth}L{.75\linewidth}@{}}
 }
 {\end{tabular}}

\NewEnviron{cvitem}[4]{%
  \xdef\cvitembody{%
    \unexpanded{#3\par#4 & {\bfseries #1}, #2\tabularnewline}%
    \noexpand\begin{itemize}%
    \unexpanded\expandafter{\BODY}%
    \noexpand\end{itemize}\noexpand\tabularnewline
  }%
  \aftergroup\cvitembody
}

\begin{document}

\begin{cvsection}{Education}
  \begin{cvitem}{xxx}{xx}{xx}{xx}
  \item x
  \end{cvitem}
\end{cvsection}

\end{document}

enter image description here

0

I came up with a workaround, using commands instead of environments. I do not understand why this works, and the code in the original question doesn't.

\documentclass[12pt]{article}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{enumitem}

\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\newenvironment{cvsection}[1]{
    { \Large \bf #1 }
    \hrule height 0.5pt
    \begin{tabular}{@{}>{}L{.25\linewidth}L{.75\linewidth}@{}}
} {
    \end{tabular}
}

\newcommand{\cvitembegin}[4]{
    #3 \linebreak #4 & 
    {\bf #1}, #2 \linebreak
    \begin{itemize}[noitemsep,nolistsep]
}
\newcommand{\cvitemend}{
    \end{itemize}\\
}

\begin{document}
\begin{cvsection}{Education}
    \cvitembegin{xxx}{xx}{xx}{xx}
        \item x
    \cvitemend
\end{cvsection}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.