2

I'm trying to format work headings in a resume that meet the following constraints:

  • The company name is left aligned and takes up a fixed width, e.g. 2.5cm.
  • The job titles are all left aligned with each other.
  • The years are right aligned at \textwidth.
  • The text sits on a baseline grid.

Like so:

Work Experience

Bar Company        Job Title                 2017-present
Job description....

Foo Company        Job Title                    2015-2017
Job description....

This is possible with a table as described in Three fixed width columns for cv entry. The problem with a table is that it's more difficult to align to a baseline grid than using a one line paragraph.

Here's kind of what I want to write:

\hbox to 4cm {Bar Company} Job Title \hfill 2017-present

Full context and MWE:

I'm using Context with a baseline grid with two columns. \WorkHeading and \WorkHeadingTable are the relevant commands.

\setuppapersize[letter]
\setuplayout[grid=yes]

\define\GoldenRatio{0.61996}
\defineparagraphs[GoldenColumns][n=2]
\setupparagraphs[GoldenColumns][1][width=\GoldenRatio\textwidth]
\define[3]\WorkHeading{#1 -- #2 \hfill #3}

\starttexdefinition WorkHeadingTable #1#2#3
  \startembeddedxtable[option=stretch,loffset=-1.8pt,roffset=-2.1pt]
    \startxrow
      \startxcell[width=4cm] #1 \stopxcell
      \startxcell #2 \stopxcell
      \startxcell \hfill #3 \stopxcell
    \stopxrow
  \stopembeddedxtable
\stoptexdefinition

\showgrid
\showframe

\starttext
\startGoldenColumns
Elon Musk
\blank[3*line]

Work Experience

\WorkHeading{Tesla}{CEO}{2016-present}
\startitemize
\item Nunc eleifend leo vitae magna. Mauris ac felis vel velit tristique
  imperdiet.  Vestibulum convallis, lorem a tempus semper, dui dui euismod elit,
  vitae placerat urna tortor vitae lacus.
\item Aliquam feugiat tellus ut neque.
\stopitemize

\WorkHeadingTable{Solar City}{CEO}{2012-present}
\startitemize
\item Nunc eleifend leo vitae magna. Aenean in sem ac leo mollis blandit.
\item Donec at pede.
\stopitemize

\GoldenColumns
elon-musk@tesla.com
\blank[3*line]
Rockets

Praesent augue. Nam vestibulum accumsan nisl.  Donec at pede.Praesent fermentum
tempor tellus.
\stopGoldenColumns
\stoptext

Minimal Working Example (Context Mkiv)

  • Why do you insist on using a table when \hbox to 4cm {...} works just fine? – Henri Menke Jul 8 '17 at 22:54
  • \hbox to 4cm{Foo} Bar \hfill 2016-present places Foo on it's own line. I want all text on the same line. – Joe Jul 8 '17 at 23:02
  • \dontleavehmode\hbox to 4cm{Foo} Bar \hfill 2016-present – Henri Menke Jul 8 '17 at 23:03
  • Thanks! Care to make it an answer? – Joe Jul 8 '17 at 23:05
5

A table is unnecessary at this point and also feels kind of overkill. You already proposed a solution yourself, namely

\hbox to 4cm {Bar Company} Job Title \hfill 2017-present

Then you noticed, that this gets split across lines. The reason for that is that in TeX a box does not start a new paragraph. The hbox will be appended to the existing vertical list and only the letter J of »Job Title« will start the paragraph. Therefore you manually have to start the paragraph before the box. You can do this by saying either \dontleavehmode or, if you want to suppress the indentation box (in case you have non-zero \parindent), with \noindent.

Furthermore I presume that you'd like to have the contents of the hbox left-aligned. This can easily be achieved by inserting filling glue to the right of the content, i.e. \hbox to 4cm{Bar Company\hfil}. Otherwise the interword space would be stretched such that the content fills the whole box, which is probably not desired in this case. (Also you would get a message in the log about an underfull hbox).

\setuppapersize[letter]
\setuplayout[grid=yes]

\define\GoldenRatio{0.61996}
\defineparagraphs[GoldenColumns][n=2]
\setupparagraphs[GoldenColumns][1][width=\GoldenRatio\textwidth]
\define[3]\WorkHeading{%
  \dontleavehmode
  \hbox to 4cm{#1\hfil} #2 \hfill #3}

\showgrid
\showframe

\starttext
\startGoldenColumns
Elon Musk
\blank[3*line]

Work Experience

\WorkHeading{Tesla}{CEO}{2016-present}
\startitemize
\item Nunc eleifend leo vitae magna. Mauris ac felis vel velit tristique
  imperdiet.  Vestibulum convallis, lorem a tempus semper, dui dui euismod elit,
  vitae placerat urna tortor vitae lacus.
\item Aliquam feugiat tellus ut neque.
\stopitemize

\WorkHeading{Solar City}{CEO}{2012-present}
\startitemize
\item Nunc eleifend leo vitae magna. Aenean in sem ac leo mollis blandit.
\item Donec at pede.
\stopitemize

\GoldenColumns
elon-musk@tesla.com
\blank[3*line]
Rockets

Praesent augue. Nam vestibulum accumsan nisl.  Donec at pede.Praesent fermentum
tempor tellus.
\stopGoldenColumns
\stoptext

enter image description here

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.