1

I'm looking to define a section-like command for a CV document that takes three arguments: role, company, and time - like shown below. Because I lack the TeX experience I used the titlesec package but it feels a little forced as section titles don't have three parameters.

My own attempt in TeX, show below as \exp, works kind of but breaks down in situations where it needs to be clever about page breaks and other corner cases. I was not able to reverse engineer the code that titlesec uses and would be grateful for a direct implementation of such a title command. It doesn't need to create a TOC entry.

\documentclass{article}
\usepackage[explicit]{titlesec}

\titlespacing*{\subsection}{0pt}{*2}{0pt}
\titleformat{\subsection}
    {\normalfont\sffamily}
    {}{0pt}{#1}
\def\experience#1#2#3{\subsection{\textbf{#3} -- #1\hfill #2}}

\begin{document}


\experience{Startup Inc.}{June 2013 -- June 2015}{Developer}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet. 

\def\exp#1#2#3{
    \ifhmode\par\fi
    \removelastskip
    \vskip2ex plus 0.5ex minus 0.3 ex\goodbreak
    \hbox to \hsize{\sffamily\textbf{#3} -- #1\hfill #2}
    \nobreak}

\exp{Startup Inc.}{June 2013 -- June 2015}{Developer}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet. 

\end{document}

enter image description here

  • What's the problem in using the \experience command? – egreg Sep 25 '15 at 9:25
  • 1
    out of topic: \exp is already defined in amsmathpackage. It is not good idea to use the same name for different purposes, regardless that you probably not use in your CV :-) – Zarko Sep 25 '15 at 9:48
  • @egreg There is no problem per se in terms of the result. I just feel that this is not what titlesec was made for or supports and I'm curious how this would be implemented in either TeX or LaTeX. @Zarko: I just picked something as I didn't want to override \experience such that we can keep them apart in the discussion. – Christian Lindig Sep 25 '15 at 10:05
  • Are you sticking to \experience as wrapper for a \subsection or should \subsection be changed as well? – user31729 Sep 25 '15 at 16:24
  • 1
    @ChristianLindig: You could take a look into latex.ltx, especially for \@startsection and @sect, but the easiest way is to grab \subsection in a \let statement and make a wrapper around it, using \subsection* always – user31729 Sep 25 '15 at 17:28
2

A proposition, but of course not really perfect (too many design issues not clear)

\documentclass{article}
\usepackage{xparse}
\usepackage{letltxmacro}


\makeatletter
\LetLtxMacro\orig@subsection\subsection

\NewDocumentCommand{\experience}{mmm+m}{%
  \orig@subsection*{\textbf{#3}  -- #1\hfill #2}
#4%
}
\makeatother



\begin{document}


\experience{Startup Inc.}{June 2013 -- June 2015}{Developer}{%

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet. 
}

\experience{\LaTeXe\ Inc.}{June 1997 -- June 2060}{Core user}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet. 

\end{document}

enter image description here

1

The main problem here is not to allow page breaks between the title and the text; I see nothing bad in using \subsection, as the document seems to be a CV.

I'd suggest an environment, so you can decide later whether allowing page breaks in the body.

\documentclass{article}

\usepackage{titlesec}

\titlespacing*{\subsection}{0pt}{*2}{0pt}
\titleformat{\subsection}
    {\normalfont\sffamily}
    {}{0pt}{}


\newenvironment{experience}[3]
 {\subsection{\textbf{#3} -- #1\hfill #2}}
 {\par}

\begin{document}


\begin{experience}{Startup Inc.}{June 2013 -- June 2015}{Developer}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet.
\end{experience}

\begin{experience}{Startup Inc.}{June 2013 -- June 2015}{Developer}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
amet.
\end{experience}

\end{document}

enter image description here

You can ensure no page breaks with

\newenvironment{experience}[3]
 {\subsection{\textbf{#3} -- #1\hfill #2}
  \begin{minipage}{\textwidth}}
 {\end{minipage}\par}

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.