2

In an effort to find a workaround for another problem (posted as a question here) I am willing to set up my book (based on the KOMA-script class scrbook) with a symmetrical layout. Like before, I would like to also create margin notes alongside the main text. Here's a MWE to illustrate, what I have so far:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{MyBook}[2016/10/01 My Book Class]

% General setup
\RequirePackage{blindtext}
\RequirePackage{leading}
\RequirePackage{calc}
\RequirePackage{color}
\definecolor{orange}{rgb}{1.0, 0.5, 0.0}
\newcommand\pagedivisions{14}

% Page Layout
\LoadClass[
  a4paper,
  twoside,
  titlepage,
  fontsize = 9pt,
  parskip = full,
  headings = small,
  index = totoc,
  listof = totoc,
  bibliography = totoc,
  numbers = noenddot,
  appendixprefix = true,
  captions = nooneline
]{scrbook}

\newlength{\completemargin}
\setlength{\completemargin}{4.125cm}

\RequirePackage{geometry}
\geometry{
  reversemarginpar,
  inner  = 21cm /  \pagedivisions,
  outer  = 21cm / \pagedivisions * 2 + \completemargin,
  top    = 29.7cm / \pagedivisions,
  bottom = 29.7cm / \pagedivisions,
  heightrounded
}

% Use scrlayer-scrpage, so that package notecolumn works
\RequirePackage[
  headwidth = 21cm - 21cm / \pagedivisions * 3 : 0cm,
  footwidth = 21cm - 21cm / \pagedivisions * 3 : 0cm,
  plainheadsepline,
  headsepline = 1pt,
  plainfootsepline,
]{scrlayer-scrpage}

% Set up the note column
\RequirePackage{scrlayer-notecolumn}
\newlength{\notescolwidth}
\setlength{\notescolwidth}{\completemargin - \marginparsep}

\DeclareNewNoteColumn[
  normalmarginpar,
  width = \notescolwidth,
  font = \raggedright\footnotesize\color{orange}
]{notes}

And here's a sample file for testing the layout:

\documentclass[english]{MyBook}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{babel}
\begin{document}

\chapter{Chapter Heading}

\Blindtext[2]

\section{Section Heading}

\makenote[notes]{Here's a note for the new note column. Just for testing purposes.}\Blindtext[4]

\subsection{Sub Section Heading}

\makenote[notes]{Here's a note for the new note column. Just for testing purposes.}\Blindtext[3]
\end{document}

Compiled with LyX the layout looks like this:

enter image description here

I guess, you can already see the problem: Is there a way for aligning the baselines of (at least the first line of) the margin notes to the paragraphs they belong to? Please note that this has to be done in the class file (no changes in the main LyX file, please), as that same book will be compiled into different layouts in the future.

Any help will be much appreciated.

6

You placed your notes between paragraphs where LaTeX was still in vmode. If you want to align the notes with the next paragraph, you should place it IN the next paragraph. You can use things like \leavevmode, \noindent, \null or \strut to place them at the very start of the next paragraph.

\documentclass[a4paper,
  twoside,
  titlepage,
  fontsize = 9pt,
  parskip = full,
  headings = small,
  index = totoc,
  listof = totoc,
  bibliography = totoc,
  numbers = noenddot,
  appendixprefix = true,
  captions = nooneline]{scrbook}
%\usepackage[T1]{fontenc}
%\usepackage[latin9]{inputenc}
% General setup
\usepackage{blindtext}
\usepackage{leading}
\usepackage{calc}
\usepackage{color}
\definecolor{orange}{rgb}{1.0, 0.5, 0.0}
\newcommand\pagedivisions{14}

\newlength{\completemargin}
\setlength{\completemargin}{4.125cm}

\RequirePackage{geometry}
\geometry{
  reversemarginpar,
  inner  = 21cm /  \pagedivisions,
  outer  = 21cm / \pagedivisions * 2 + \completemargin,
  top    = 29.7cm / \pagedivisions,
  bottom = 29.7cm / \pagedivisions,
  heightrounded
}

% Use scrlayer-scrpage, so that package notecolumn works
\usepackage[
  headwidth = 21cm - 21cm / \pagedivisions * 3 : 0cm,
  footwidth = 21cm - 21cm / \pagedivisions * 3 : 0cm,
  plainheadsepline,
  headsepline = 1pt,
  plainfootsepline,
]{scrlayer-scrpage}

% Set up the note column
\usepackage{scrlayer-notecolumn}
\newlength{\notescolwidth}
\setlength{\notescolwidth}{\completemargin - \marginparsep}

\DeclareNewNoteColumn[
  normalmarginpar,
  width = \notescolwidth,
  font = \raggedright\footnotesize\color{orange}
]{notes}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
%\usepackage{babel}
\begin{document}

\chapter{Chapter Heading}

\Blindtext[2]

\section{Section Heading}

\leavevmode\makenote[notes]{Here's a note for the new note column. Just for testing purposes.}\Blindtext[4]

\subsection{Sub Section Heading}

\strut\makenote[notes]{Here's a note for the new note column. Just for testing purposes.}\Blindtext[3]
\end{document}

To always add \leavevmode:

\let\oldmakenote=\makenote
\def\makenote{\ifvmode\leavevmode\fi\oldmakenote}
  • Oh, I wasn't aware that I was placing the note between the paragraphs... I thought, the beginning of the current paragraph was also part of the paragraph? Anyway: Thanks, that worked well. (Do you think there's a way to include \leavevmode in the class file somehow, so that the people typing the main text do not have to remember the command?) – Marcus C. Oct 11 '16 at 15:47
  • 1
    If you mean replacing \makenote, that can be done, but I'm not sure if using \leavevmode when not in vmode is a good idea. – John Kormylo Oct 11 '16 at 15:55
  • Yeah, something to that effect. The problem is that the class file will also be used by other authors and I would like to hide most of the complications from them. They are using LyX and having to type Strg-L to enter \makenote as a LaTeX command is already asking a lot... :) – Marcus C. Oct 11 '16 at 16:03
  • Ah, I noticed you already edited the answer. Thanks a lot, I will try that, but it looks as if it will solve the problem. – Marcus C. Oct 11 '16 at 16:04
  • The answer saved me from having some \makenote into a new blank page. Thank you – SHY.John Nov 20 '16 at 2:07

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.