2

In my CV, I list my past (and a recent) jobs. For example:

\begin{tabular}{r@{\emph{ – }}l | p{11cm}}
  \emph{Jun 2013} & \emph{Aug 2013} & Work position at Company\\
\end{tabular}

However, I worked at some companies for less than a month: for example:

\begin{tabular}{r@{\emph{ – }}l | p{11cm}}
  \emph{Aug 2012} \span & Other Work position at Firm\\
\end{tabular}

The problem with this second example is that the \span does not remove the alignment character (i.e. ) from that particular row. So the question is: how do I remove it from selected rows?

  • 2
    Hm. Where do you learned \span? Why don't you use \multicolumn? But beside this: don't show snippets, make complete examples that can be used for tests. – Ulrike Fischer Mar 12 '19 at 21:13
  • I’ve found \span in some of the answers here on StackExchange. And on snippets vs complete examples: I just thought the snippets would be enough to show you what I would like to complete. – tukusejssirs Mar 13 '19 at 16:50
  • snippets are difficult to test. You always have to add preamble and other stuff first. – Ulrike Fischer Mar 13 '19 at 16:59
  • Here’s the particular answer in which I’ve found the \span. … Next time, I include the complete striped-down examples. :) – tukusejssirs Mar 13 '19 at 17:25

3 Answers3

1

Whereas the @ specification of the OP's MWE seems to be locked into stone (can't be changed on the fly), the same is not true of the < specification, which is re-evaluated on the fly.

\documentclass{article}
\usepackage{array}
\newcommand\mycolsep{\emph{ -- }}
\newcommand\myspan{\let\mycolsep\relax\span}
\begin{document}
\begin{tabular}{r<{\mycolsep}@{}l | p{11cm}}
  \emph{Jun 2013} & \emph{Aug 2013} & Work position at Company\\
  \emph{Aug 2012} \myspan & Other Work position at Firm\\
  \emph{Jun 2011} & \emph{Aug 2011} & Work position at Company\\
  \emph{Aug 2010} \myspan & Other Work position at Firm\\
\end{tabular}
\end{document}

enter image description here

If you want the result left-aligned, and in light of a comment by the OP, I take a slightly altered approach:

\documentclass{article}
\usepackage{array}
\newcommand\mycolsep{\emph{ -- }}
\newcommand\myspan{\def\mycolsep{\phantom{\emph{ -- }}}&}
\begin{document}
\begin{tabular}{r<{\mycolsep}@{}l | p{11cm}}
  \emph{Jun 2013} & \emph{Aug 2013} & Work position at Company\\
  \emph{Aug 2012} \myspan & Other Work position at Firm\\
  \emph{Jun 2011} & \emph{Aug 2011} & Work position at Company\\
  \emph{Jul 2010} \myspan & Other Work position at Firm\\
\end{tabular}
\end{document}

enter image description here

1

\span is a low-level tex primitive. In LaTeX you should use \multicolumn to change columns styles:

\documentclass{book}

\begin{document}
\begin{tabular}{r@{\emph{ – }}l | p{11cm}}
\emph{Jun 2013} & \emph{Aug 2013} & Work position at Company\\
\multicolumn{2}{l|}{\emph{Aug 2012}}& Other Work position at Firm\\

\end{tabular}

\end{document}

enter image description here

If you want to right align them in the first cell, you can use \phantom to fake the dash:

\documentclass{book}
\usepackage{array}
\begin{document}

\begin{tabular}{r@{\emph{~–~}}l | p{11cm}}
\emph{Jun 2013}& \emph{Aug 2013} & Work position at Company\\
\multicolumn{1}{r@{\phantom{\emph{~–~}}}}{\emph{Jul 2013}}&
& 
Other Work position at Firm\\

\end{tabular}

\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • This might more correct answer (from the don’t-use-low-level-TeX-primitives point of view) and the output is exactly the same as the \hfill solution of @Steven B Segletes (link). However, this comment of mine still applies to this answer, too. – tukusejssirs Mar 13 '19 at 17:33
  • I added an edit. – Ulrike Fischer Mar 13 '19 at 17:54
  • I like the \myspan new command from the other answer, however, I can’t seem to make it work. What I tried: \newcommand\mergecols{\def\multicolumn{1}{r@{\phantom{\mycolsep}}}{#1}} and \newcommand{\mergecols}[1]{\def\multicolumn{1}{r@{\phantom{\mycolsep}}}{#1}}. … Note that I also created \newcommand\mycolsep{~--~}. – tukusejssirs Mar 13 '19 at 19:39
  • 1
    If you would stop to use low-level tex (in this case \def) you would have less problems. Beside this: don't ask such questions in comments. Ask a new question. – Ulrike Fischer Mar 13 '19 at 19:51
0

I'd do it in a different way and with a simpler user level syntax:

\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentEnvironment{cvpart}{}
 {
  \setlength{\tabcolsep}{0pt}
  \par\noindent
  \begin{tabular*}{\textwidth}{
    r
    l
    @{\extracolsep{\fill}} p{11cm}
   }
 }
 {
  \end{tabular*}
 }

\NewDocumentCommand{\cvrow}{>{\SplitArgument{1}{--}}m m}
 {
  \tukus_cvrow:nnn #1 { #2 }
 }

\cs_new_protected:Nn \tukus_cvrow:nnn
 {
  \emph{ \tl_trim_spaces:n { #1 } }
  \tl_if_novalue:nTF { #2 }
   {
    \hphantom{~--~} &
   }
   {
    \mbox{~--~} & \emph{ \tl_trim_spaces:n { #2 } }
   }
  & #3 \\
 }

\ExplSyntaxOff

\begin{document}

\begin{cvpart}
\cvrow{Jun 2013 -- Aug 2013}{
  Work position at Company
  Work position at Company
  Work position at Company
  Work position at Company
  Work position at Company
}
\cvrow{Jul 2013}{Other Work position at Firm}
\end{cvpart}

\end{document}

The \cvrow command takes two arguments; if the first argument contains --, one branch is followed and the en-dash is printed. Otherwise just the space is allocated.

Adjust the 11cm to suit your text width.

enter image description here

egreg
  • 1,121,712