使用书籍样式的边注时出现问题

使用书籍样式的边注时出现问题

这是我之前关于使用边注提出的问题的后续这里

我发现当我使用书籍样式时,边距注释会从左侧跳到右侧,这取决于页面是奇数还是偶数,尽管我已确保添加注释\reversemarginpar以确保注释位于页面的左侧。

然后我改变了书籍样式并添加了 oneside修复该问题的内容,现在所有边距注释都显示在每页的左侧。

但由于某种原因,纸条本身现在被分成了两行小行。

即使我使用几何来增加左边距,它仍然不起作用。

下面的例子有助于说明这个问题。第一个例子使用默认值。

\documentclass[12pt]{book}
\usepackage{listings}
\usepackage{fancybox,fancyvrb,xcolor}
\usepackage{marginnote}

\definecolor{bg}{RGB}{255,255,226}
\lstdefinestyle{TEXT}{%
    basicstyle=\ttfamily\normalsize,
    breaklines=false,
    columns=fullflexible,
    keepspaces=true,
    backgroundcolor=\color{bg},
    rulecolor=\color{gray},
    language=,
    frame=single,
    frameround=tttt,
    aboveskip=12pt,belowskip=6pt
}

\lstnewenvironment{TEXTinline}{%
  \lstset{style=TEXT}}{}

\begin{document}
\reversemarginpar

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command 
  which can be very very very 
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command 
  which can be very very very 
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command 
  which can be very very very 
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command 
  which can be very very very 
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command 
  which can be very very very 
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command 
  which can be very very very 
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command 
  which can be very very very 
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command 
  which can be very very very 
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command 
  which can be very very very 
  long command
  used to process the file
\end{TEXTinline}

\end{document}

这给出

在此处输入图片描述

上面显示了问题所在。页边距根据页面从左向右移动。现在我做了与上面相同的操作,但更改\documentclass[12pt]{book}\documentclass[12pt,oneside]{book},其他一切都相同。这是结果

在此处输入图片描述

仔细观察其中的一个:

在此处输入图片描述

正确的方法是什么,才能使所有边距注释以书籍样式显示在页面左侧,且不出现此分割问题?

看起来边距注释有固定的宽度。我需要看看是否可以更改它。

Linux 上的 TL 2023

答案1

渴望评论。

当您更改\documentclass[12pt]{book}为时,\documentclass[12pt,oneside]{book}您会大量更改页面布局。要查看此内容,我建议您在评论中添加showframe显示页面布局的包。

例如,在默认的双面布局下,不使用geometry包进行的校正,页面布局如下:

在此处输入图片描述

布局oneside

在此处输入图片描述

考虑到我在第二条评论中的建议,MWE 是:

\documentclass[12pt,oneside]{book}      % <--- one side layout
\usepackage[marginpar=22mm]{geometry}   % <--- added for increasing marginpar width
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                              % for dummy text
%---------------------------------------------------------------%
\usepackage{listings}
\usepackage{fancybox,fancyvrb,xcolor}
\usepackage{marginnote}

\definecolor{bg}{RGB}{255,255,226}
\lstdefinestyle{TEXT}{%
    basicstyle=\ttfamily\normalsize,
    breaklines=false,
    columns=fullflexible,
    keepspaces=true,
    backgroundcolor=\color{bg},
    rulecolor=\color{gray},
    language=,
    frame=single,
    frameround=tttt,
    aboveskip=12pt,belowskip=6pt
}

\lstnewenvironment{TEXTinline}{%
  \lstset{style=TEXT}}{}

\begin{document}
%\reversemarginpar   % <--- removed, since this is oneside document

\marginnote{command} % removed shift
\begin{TEXTinline}
  This is my long command
  which can be very very very
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command
  which can be very very very
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command
  which can be very very very
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command
  which can be very very very
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command
  which can be very very very
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command
  which can be very very very
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command
  which can be very very very
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command
  which can be very very very
  long command
  used to process the file
\end{TEXTinline}

\marginnote{command}[12pt]
\begin{TEXTinline}
  This is my long command
  which can be very very very
  long command
  used to process the file
\end{TEXTinline}

\end{document}

并得到的结果是。

在此处输入图片描述

这就是你想要的吗?顺便说一句,在答案中我没有处理垂直位置的问题marginnote

附录:
如果您的文档仅在网络上,那么使用htmldocument 可能比更好pdf。无论如何,如果边距注释应始终位于文本左侧,则需要增加文档的左侧边距。例如

\documentclass[12pt, oneside]{book}
\usepackage[hmargin={1.5in, 1in},

(我没有费心寻找左边距的合适大小)并使用\reversemarginpar文档正文中的说明。现在的结果是:

在此处输入图片描述

在此处输入图片描述

相关内容