0

I am trying to typeset a document (a CV) so that subsection headings (and only those) are in a separate column to the left. I would also like to be able to control the fonts for content and headings (I usually use fontspec, sectsty and XeTeX for this), and maintain the "usual" document structure so that eg. pandoc can still parse it.

The parcolumns package is out, because it affects document structure too much (which is fair, it wasn't designed for this use).

I have tried the medium length graduate CV template, but that has section headings hard coded in numerous places, and won't play nice with the sectsty package, making it hard to change heading fonts. (I haven't given up on this, but it's hard enough that I feel like I'm barking up the wrong tree.)

Here's a picture of roughly what I'm aiming for: Example of subsection header in different column

What is a straightforward way to achieve this?

1

As I understand, you want something like this:

\documentclass[a4paper]{article}

\usepackage{lipsum}

% Dimensions

\textwidth=13cm
\oddsidemargin=4cm
\evensidemargin=\oddsidemargin
\topmargin=-1cm
\textheight=25cm

\makeatletter

\def\section#1{\vspace{1cm plus 5mm minus 3mm}\goodbreak\par\noindent%
    \hspace{-4cm}\parbox{17cm}{\Large\bf #1}%
    \addcontentsline{toc}{section}{#1}\@xsect{0.5\baselineskip}}

\def\subsection#1{\vspace{3pt plus 1pt minus 1pt}\par\noindent%
    \hspace{-4cm}\vbox to 0pt{\smash{\parbox[t][][b]{3.7cm}{%
    \large\noindent\raggedleft #1%
    \addcontentsline{entoc}{subsection}{#1}}}}%
    \@xsect{0.1\baselineskip}%
    \vspace{-1.5\baselineskip}}% This requires tweaking to vertically align the text corrrectly

\makeatother

\begin{document}
\section{First section}
\subsection{First subsection}
\lipsum[1]
\subsection{Second subsection with a lot of text}
\lipsum[2]
\section{Second section}
\subsection{First subsection}
\lipsum[1]
\subsection{Second subsection with a lot of text}
\lipsum[2]
\end{document}

Compilation result

To align the title to the full text width, the calc package is useful:

\usepackage{calc}

Then after the dimensions block, add:

\newlength{\fullwidth}
\setlength{\fullwidth}{\textwidth+\oddsidemargin}

...and within the \makeatletter block, do:

\def\maketitle{%
    \noindent\hspace{-\oddsidemargin}%
    \begin{minipage}{\fullwidth}%
        \begin{center}%
            {\LARGE\@title}%
        \end{center}%
    \end{minipage}}

fontspec commands will need to be inserted into the (sub)section command definitions themselves (ie. don't use titlesec or sectsty commands for those):

\usepackage{fontspec}

\newfontfamily\subsectionfont{Some Font}

[...]

\def\subsection#1{\vspace{3pt plus 1pt minus 1pt}\par\noindent%
    \hspace{-4cm}\vbox to 0pt{\smash{\parbox[t][][b]{3.7cm}{%
    \large\noindent\raggedleft\subsectionfont #1%

Finally, if you use hyperref to get a PDF index, you'll need to add \phantomsection commands to avoid your page numbers being wrong:

    \large\noindent\raggedleft #1%
    \phantomsection%
  • This is great! Much simpler than hacking on res.cls. One quibble: the ragged right alignment of the subsections doesn't seem to be doing what I'd expect (right alignment, no justification). – detly Mar 30 '16 at 6:35
  • Also the document title seems to shift across to align with the text, even though both margins are equal. What causes that? – detly Mar 30 '16 at 6:56
  • @detly, '\raggedright' means that text would be aligned by left. To make document title you can redefine \maketitle or put it into minipage: \noindent\hspace{-4cm}\begin{minipage}{17cm} \maketitle \end{minipage} – Eddy_Em Mar 30 '16 at 7:43
  • Hah, I just needed \raggedleft there. I'll fiddle with the title to get it right. Finally, is there a foolproof way to vertically align the top of the subsection heading and the paragraph text? Or is it just trial and error with the measurements? – detly Mar 30 '16 at 7:45
  • I've edited your answer with all the tweaks and notes I used to neaten things up. – detly Mar 30 '16 at 11:44

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.