5

I'm interested in achieving a two-column layout like the following, where the columns are flush with the left and right margins of the page:

| section heading | lorem ipsum lorem ipsum lorem ipsum lorem ipsum |
|                 | lorem ipsum lorem ipsum lorem ipsum lorem ipsum |
|                 | lorem ipsum lorem ipsum lorem ipsum lorem ipsum | 
|                 |                       ...                       |

The basic shape is of course easy to achieve with a (long)table, but the compiler doesn't know what to do with a \section{...} command inside a table.

Another possibility is to use titlesec with the leftmargin option, as described here, but this places the section heading in the left margin, rather than making its left edge flush with the left margin. The desired effect could be achieved by manually tweaking the margins, but I am wondering if a cleaner solution is possible.

SEC
  • 761

2 Answers2

3

Here I start with the code given in the question cited by the OP.

I don't know the actual numbers are precise, but a \leftskip can be used to compensate for the leftmargin value. I show in this MWE a transition back to the original sectioning system, which must be accompanied by a cancellation of the \leftskip.

\documentclass{article}
\usepackage[showframe]{geometry}

%to lyn preamble from here
\let\svsection\section
\usepackage{titlesec}

\titleformat{\section}[leftmargin]
{\normalfont
\sffamily\bfseries\filleft}
{}{0pt}{}
\titlespacing{\section}
{4pc}{1.5ex plus .1ex minus .2ex}{1pc}

%to here

\begin{document}
\leftskip 1in
\section{Objective}
\noindent
Auditing/Analysis of Operations

\section{Education}
\noindent
B.S. in Management, Rensselaer Polytechnic Institute, Troy, NY, May 1986
Concentrations in Accounting and Management Systems
QPA 3.9 in major, 3.7 overall

\section{A very long section title}
\noindent
B.S. in Management, Rensselaer Polytechnic Institute, Troy, NY, May 1986
Concentrations in Accounting and Management Systems
QPA 3.9 in major, 3.7 overall
B.S. in Management, Rensselaer Polytechnic Institute, Troy, NY, May 1986
Concentrations in Accounting and Management Systems
QPA 3.9 in major, 3.7 overall
B.S. in Management, Rensselaer Polytechnic Institute, Troy, NY, May 1986
Concentrations in Accounting and Management Systems
QPA 3.9 in major, 3.7 overall

\leftskip 0in
\let\section\svsection
\section{A very long section title}
\noindent
B.S. in Management, Rensselaer Polytechnic Institute, Troy, NY, May 1986
Concentrations in Accounting and Management Systems
QPA 3.9 in major, 3.7 overall
B.S. in Management, Rensselaer Polytechnic Institute, Troy, NY, May 1986
Concentrations in Accounting and Management Systems
QPA 3.9 in major, 3.7 overall
B.S. in Management, Rensselaer Polytechnic Institute, Troy, NY, May 1986
Concentrations in Accounting and Management Systems
QPA 3.9 in major, 3.7 overall


\end{document}

enter image description here

  • If the leftmargin section title is immediatly followed by a subsection tilte (e.g. \section{a title}\subsection{a title})rather than followed by common text, they are not horizontally aligned. How to deal with this problem? – lyl Feb 27 '19 at 02:51
  • @lyl I am not even sure how one would want \subsection to behave in such circumstances. – Steven B. Segletes Feb 27 '19 at 03:18
  • In some conditions, \subsection is useful. I think the problem of align with section title comes from the default vertical spacing, but modifing these spacing of \subsection by \titlespacing does not succeed. So I'm looking if there is an approach to solve it. – lyl Feb 27 '19 at 03:27
  • @lyl Still not clear what you want. If I do \titleformat{\subsection}[leftmargin] {\normalfont \sffamily\bfseries\filleft} {}{0pt}{} \titlespacing{\subsection} {4pc}{1.5ex plus .1ex minus .2ex}{1pc} and employ \subsection{subEd} \noindent B.S. in Management, Rensselaer Polytechnic Institute,... it looks like \section behavior. So what do you seek? – Steven B. Segletes Feb 27 '19 at 03:38
  • Sorry, I'd like to clearify my seek. section title in left margin like this post. subsection title in nomal position(in main body). if \subsection{...} is the first element after \section{...}, then I want the title of subsection is top aligned with section title(that in left margin). Or would you please have a look at this post "https://tex.stackexchange.com/questions/476713/subsection-title-does-not-align-with-its-section-title-under-left-margin" – lyl Feb 27 '19 at 04:05
  • @lyl I looked at your question. It looks like a difficult problem, given that you need \vspaces to even try to make it work. – Steven B. Segletes Feb 27 '19 at 04:21
  • This will cause many times of tring a correct value for \vspace, and when the font size changes, the value has to be tried again, and it's boring each time \vspace has to be introduced. So I wonder if there is a solution to automatically top align titles of subsections and its sections when section title is in left margin. – lyl Feb 27 '19 at 04:26
2

You do want to shift the left margin and to typeset the section title in the margin.

\documentclass[a4paper]{article}
\usepackage[showframe]{geometry}
\usepackage{titlesec}

\usepackage{lipsum}

\geometry{left=6cm,right=3cm} % 3cm for the sections
\titleformat{\section}[leftmargin]
  {\normalfont\bfseries\filright}
  {\thesection}
  {1em}
  {}
\titlespacing*{\section}
  {3cm}
  {2ex plus .2ex minus .2ex}
  {1sp}% should be 0, but it must be positive

\begin{document}

\lipsum[2]

\section{A title}

\lipsum[3]

\section{A very very very very very long title}

\lipsum[3]

\end{document}

enter image description here

egreg
  • 1,121,712
  • Thanks, this is a nice solution, but not exactly what I was looking for. E.g., the page number is off-center, and one cannot move back and forth between sections in the normal style and sections in the custom style. – SEC Apr 09 '16 at 14:36