I'm currently working on a book project in LaTeX and LyX and found a weird bug that seems to crash LaTeX. I have no idea how to work around that crash, so I thought I'd ask for help here.
In a nutshell: I'm using the KOMA-script class scrbook
to create a document of size A4 and would like to set up margin notes alongside the main text. I read a lot about different procedures for that and decided to try the scrlayer-notecolumn
package to avoid the disadvantages of the other methods.
For greater clarity, I would like to be able to indent all regular paragraphs, but leave chapter and section headings unindented. I already managed to set that up (but I'm open for suggestions, in case this should be done differently). Here's a MWE for the class file:
\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\pagedividers{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}
\RequirePackage{geometry}
\geometry{
reversemarginpar,
inner = 21cm / \pagedividers,
outer = 21cm / \pagedividers * 2,
top = 29.7cm / \pagedividers,
bottom = 29.7cm / \pagedividers,
heightrounded
}
% Use scrlayer-scrpage, so that package notecolumn works
\RequirePackage[
plainheadsepline,
plainfootsepline,
]{scrlayer-scrpage}
% Set up the note column
\RequirePackage{scrlayer-notecolumn}
\RequirePackage{scrextend}
\newlength{\completemargin}
\setlength{\completemargin}{4.125cm}
\newlength{\notescolwidth}
\setlength{\notescolwidth}{\completemargin - \marginparsep}
\DeclareNewNoteColumn[
marginpar,
position = \ifthispageodd{\oddsidemargin + 1in}{\evensidemargin + 1in},
width = \notescolwidth,
font = \raggedright\footnotesize\color{orange}
]{notes}
% Indent the paragraphs, lists, equations and subsections
\RequirePackage{enumitem}
\setlength{\leftskip}{\completemargin}
\setlist[itemize]{leftmargin = \completemargin}
\setlist[enumerate]{leftmargin = \completemargin}
\setlist[description]{leftmargin = \completemargin + 1cm, labelindent = \completemargin}
\addtokomafont{subsubsection}{\setlength{\leftskip}{\completemargin}}
\addtokomafont{paragraph}{\setlength{\leftskip}{\completemargin}}
\addtokomafont{subparagraph}{\setlength{\leftskip}{\completemargin}}
\RequirePackage[fleqn]{amsmath}
\setlength{\mathindent}{\completemargin + 1cm}
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}
This, of course, give me an asymmetrical layout. And here's where my problem starts:
The note column (notes
in the above example) needs to be to the left of the main text, both on the odd and on the even pages. As the outer and inner margins are different, I need a way to check, if I'm on an odd or even page, when setting the position of the note column. I do this - as suggested - by using \ifthispageodd
from package scrextend
.
This, however, crashes LaTeX (or pdflatex, when called from LyX).
I'm really not sure how to work around that. If I remove \ifthispageodd
and use, e.g., \oddsidemargin
instead, the pages look like that:
So, is there any other way for checking odd or even pages? Or is there a command that I can use for reading out the actual left margin of the current page (instead of \oddsidemargin
in the above MWE). Or should I use a different procedure for setting up the note column? Any help would be much appreciated.
Oh, by the way: If anybody has an idea how to align the baseline of the notes in the note column with the main text, I'd be very happy, as well.