如何使 LaTeX 中的边注基线与正文对齐?

如何使 LaTeX 中的边注基线与正文对齐?

为了找到另一个问题的解决方案(以问题形式发布这里)我愿意建立我的书(基于KOMA 脚本scrbook)具有对称布局。像以前一样,我还想创建边注在正文旁边。下面是 MWE,用于说明我目前所拥有的内容:

\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}

下面是用于测试布局的示例文件:

\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}

使用 LyX 编译的布局如下所示:

在此处输入图片描述

我想,你已经看到了问题所在:有没有办法对齐基线边注(至少是第一行)与它们所属的段落的对应关系?请注意,这必须在类文件中完成(请勿更改主 LyX 文件),因为同一本书将来会被编译成不同的布局。

任何帮助都感激不尽。

答案1

您将注释放在了 LaTeX 仍处于 vmode 的段落之间。如果您想将注释与下一个段落对齐,则应将其放在下一个段落内。您可以使用 、\leavevmode\noindent\null符号\strut将它们放在下一个段落的最前面。

\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}

总是添加\leavevmode

\let\oldmakenote=\makenote
\def\makenote{\ifvmode\leavevmode\fi\oldmakenote}

相关内容