[Tex/LaTex] Margin notes (and subsection titles) in both sides of a two column document

marginpartitlesectwo-column

I would like to write a book document with two columns and subsubsection titles as margin notes at both sides of the page (in the side which corresponds to the column).

In order to specify the subsubsection titles I have used a simple variation of titlesec example code:

\newcommand{\secformat}[1]{\MakeLowercase{\so{#1}}}
% \so spaces out letters
\titleformat{\subsubsection}[block]
{\normalfont\scshape\filcenter}
{\thesubsubsection}
{1em}
{\secformat}
% La subsubseccion
\titleformat{\subsubsection}[leftmargin]
{\normalfont
\titlerule*[.6em]{\bfseries.}%
\vspace{6pt}%
\sffamily\bfseries\filleft}
{\thesubsubsection}{.5em}{}
\titlespacing{\subsubsection}
{4pc}{1.5ex plus .1ex minus .2ex}{1pc}

As you can see following image, margin titles are located in the left side as it's set as a fixed parameter in the code, so titles are over the text in the right column.

two-column example

I would like to know how I can check dynamically if the title corresponds to the right or the left column and to put it in the real margin: I suppose it could be done by setting the parameter [leftmargin] or [rightmargin] but I'm not sure 😕

Best Answer

I'm not sure how much flexibility you have in changing base document classes, but the memoir class includes features similar to titlesec, and doesn't exhibit this problem by default.

\documentclass[twocolumn]{memoir}
\usepackage{lipsum}
\settrimmedsize{11in}{210mm}{*}
\setlength{\trimtop}{0pt}
\setlength{\trimedge}{\stockwidth}
\addtolength{\trimedge}{-\paperwidth}
\settypeblocksize{7.75in}{33pc}{*}
\setulmargins{4cm}{*}{*}
\setlrmargins{1.25in}{*}{*}
\setmarginnotes{17pt}{51pt}{\onelineskip}
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{*}{2\onelineskip}{*}
\checkandfixthelayout

\begin{document}
\chapter{Chapter Title}
\section{Section Title}
\marginpar{\subsection{Subsection Title 1}}{\lipsum[1-3]}
\marginpar{\subsection{Subsection Title 2}}{\lipsum[4]}
\end{document}

Here, I'm using the page layout used in the memoir manual (section 2.9.1). You'd need to read through their page layout documentation and adjust for your needs.

Results:

Memoir marginpar example