# Alignment marginnotes

I am trying to write a report for Uni, where I need something like what marginnotes does. The problem is I would need two different margins on the left side of the page. One for the chapter or section title and one for the paragraph, and to the left side of the paragraph there should be a block title, horizontally aligned to the title, which doesn't appear in the toc. maybe this example can give you an idea of what I'm looking for.

\documentclass[10pt,twoside,a4paper,fleqn]{report}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel,varioref}
\usepackage{marginnote, scrextend, etoolbox, titlesec}

%always put marginals on the left side of the page
\makeatletter
\patchcmd{\@mn@margintest}{\@tempswafalse}{\@tempswatrue}{}{}
\patchcmd{\@mn@margintest}{\@tempswafalse}{\@tempswatrue}{}{}
\reversemarginpar
\makeatother

\titlespacing*{\section}{-3cm}{\parskip}{\parskip}
\titlespacing*{\chapter}{-3cm}{\parskip}{\parskip}

\begin{document}
\chapter{Model chapter for a report}
This is the first chapter of the report.

\section{Model section}
\marginnote{This is a marginal}This is the first section of the first chapter of the report

\end{document}


The problem is, although the paragraph has an added 3cm of margin, the marginal will not be aligned to the title, and even be cut off by the page border. I know I could simply change the geometry settings, but this is not quite what I need, since the section and chapter titles will then also be moved into the page.

• The example doesn't compile. \patchcmd and addmargin are not defined. Beside this I don't understand the question but your use of addmargin looks odd. Probably you want to know how to move the titles in the margin. – Ulrike Fischer May 10 '13 at 11:12
• I'm sorry I forgot to add the scrextend and etoolbox packages. What I need is a marginal note underneath the titles, horizontally aligned with them. the marginal note would work as a block title next to the paragraph block. I'm quite sure moving the titles into the margin would work just as well. I also edited the MWE. – David Wright May 10 '13 at 11:17
• I think you're doing this the wrong way: it seems like you want chapter and section headings shifted into the margin but instead you make a mini margin and shift the text parts to the right. The other way around would seem to make more sense: make a bigger margin and use e.g. titlesec to modify the headings. Then you wouldn't need {addmargin} and the problem with the \marginnote would disappear. – clemens May 10 '13 at 11:25
• That sounds like a nice way to work it out! Unfortunately I'm not really familiar with the titlesec package and simply using \titleformat{\section}[leftmargin] or \titleformat{\chapter}[leftmargin]like I've seen online doesn't seem to work. Could you maybe give me some more input? – David Wright May 10 '13 at 11:38
• Okay I added two lines in the preamble of which one works. The \section is moved to the left just as expected, the \marginnote{} works as well, but the \chapter won't change.. – David Wright May 10 '13 at 11:55

I think something along these lines can be achieved with the titlesec package (and no doubt others too!). I find it voodoo-ish (and, for a person like me, I could do with more examples in the documentation), but this seems to work:

For the section

\newcommand{\titlebox}[1]{%
\parbox[t]{2.5cm}{\raggedright #1}}

\titleformat{\section}
[leftmargin]% type is "marginal"
{\bfseries}%  format
{}%           no label used
{0pt}%        no need for any separation
{\titlebox}%  command to set title

\titlespacing{\section}
{3cm}%      width of marginal
{*1}%       space before
{*0}%       and after


We define \titlebox{} simply as a convenient way of having a single argument macro that will typeset the material in an appropriate box, ragged right. The key (I think) is the first argument in \titlespacing which controls the width of the marginal. (I have assumed that an extra 3 cm is added to the margin to allow for titles -- in the example I've set a 5cm left margin and a 2cm right margin.)

For the chapter title, we use a slightly different method to get it to hang appropriately into the left margin, but I think that's obvious from the example that follows.

\documentclass{report}

\usepackage{titlesec}

\newcommand{\titlebox}[1]{%
\parbox[t]{2.5cm}{\raggedright #1}}

\titleformat{\section}
[leftmargin]
{\bfseries}
{}
{0pt}
{\titlebox}

\titleformat{\chapter}
[hang]
{\bfseries\Large}
{}
{0pt}
{}
[{\titlerule[1pt]}]

\titlespacing{\section}
{3cm}
{*1}
{*0}

\titlespacing{\chapter}
{-3cm}
{*2}
{*2}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}

\begin{document}

\section{Summary of Work}

The object of this report is to show how one can produce marginal section headings, in this fashion. Similar things could and would need to be done for subsections and the like.

\section{Date}
May 10, 2013, London.

\section{Author}
Paul Stanley.

\end{document}


The end result:

Please note that I have manually set \parskip only for demonstration purposes: for a real document you might well want to use a package for such things.

Thank you all very much. I've been able to work out how to move the chapter headings to the left margin. In the titlesec package it says:

Notes. \titlespacing does not work with either \chapter and \part unless you change its title format as well by means of \titleformat, the simple settings, or \titleclass.

In the following MWE I managed to get it all running the way it should:

\documentclass[10pt,twoside,a4paper,fleqn]{report}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel,varioref}
\usepackage{marginnote, scrextend, etoolbox, titlesec}

%always put marginals on the left side of the page
\makeatletter
\patchcmd{\@mn@margintest}{\@tempswafalse}{\@tempswatrue}{}{}
\patchcmd{\@mn@margintest}{\@tempswafalse}{\@tempswatrue}{}{}
\reversemarginpar
\makeatother
\setlength{\parindent}{0cm}

\titlespacing*{\section}{-4.2cm}{\parskip}{\parskip}
\titleformat{\chapter}[display]{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{-4.2cm}{\parskip}{\parskip}[{\titlerule[1pt]}]

\begin{document}

\chapter{Model chapter for a report}
This is the first chapter of the report.

\section{Model section}
\marginnote{This is a marginal}This is the first section of the first chapter of the report

\end{document}


That was pretty much the document structure I needed

As for your answer Paul Stanley, I see what you did, you moved the section and chapter headings into the margins, which would be a nice way to bring that sort of structure into the document. I tried that as well but the professor told us that the margin notes should be block titles which should not be titles that appear in the toc or anywhere else, just titles that should bring some structure to the document. I like it that way though, and I definitely will consider writing a document like that outside of uni or for another professor.

Again, thanks for all the help, I hope this will help someone else as well.

EDIT: Unfortunately this affects the toc, the tot, the bibliography and the index of a document as well, but not the titlepage, tof and the glossary, the are not moved to the left of the document.