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?

4
  • 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. Commented Mar 12, 2019 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. Commented Mar 13, 2019 at 16:50
  • snippets are difficult to test. You always have to add preamble and other stuff first. Commented Mar 13, 2019 at 16:59
  • Here’s the particular answer in which I’ve found the \span. … Next time, I include the complete striped-down examples. :) Commented Mar 13, 2019 at 17:25

3 Answers 3

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

4
  • 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. Commented Mar 13, 2019 at 17:33
  • I added an edit. Commented Mar 13, 2019 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{~--~}. Commented Mar 13, 2019 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. Commented Mar 13, 2019 at 19:51
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

5
  • Perfect! Works as expected. :) Commented Mar 13, 2019 at 16:53
  • I like the solution with \hfill, however, it would be nice to have the date right-aligned towards the \mycolsep. What I mean is that all dates are centred at the \mycolsep. When you use e.g. Jul 2012, which is a bit shorter than Aug 2010, you’ll see what I mean. I have no idea if it can be accomplished. Commented Mar 13, 2019 at 17:16
  • @tukusejssirs That could be tough using this approach. Let me think some more. Commented Mar 13, 2019 at 17:23
  • @tukusejssirs Please see my edit. I think it accomplishes what you ask. Commented Mar 13, 2019 at 17:27
  • Now it looks as I imagined it! :) … Thank you! :) Commented Mar 13, 2019 at 17:38
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

You must log in to answer this question.

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