使用 makeatletter/addtoreset 的旁注以注释 0 开头,而不是 1

使用 makeatletter/addtoreset 的旁注以注释 0 开头,而不是 1

我想重新对每个小节的旁注进行编号,以防止在书的末尾出现 1000 个旁注。因此我使用以下代码:

\documentclass[10pt]{book}
\usepackage{geometry}

\usepackage[utf8]{inputenc}
\usepackage[latin]{babel}
\usepackage{sidenotes}
\usepackage{blindtext}
\usepackage[maxfloats=100]{morefloats}

\setlength{\marginparwidth}{2cm}

\makeatletter
\@addtoreset{sidenote}{subsection}
\makeatother

\begin{document}

\chapter{Hello}

\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}

\chapter{Hi}

\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}\blindtext\sidenote{hello}

\end{document}

但问题是,每个部分(章节)的旁注都是从旁注 0 开始,而不是从旁注 1 开始。我该如何解决这个问题?或者这是一个错误?

答案1

\sidenote如果没有出现,你就会遇到问题一个\subsection命令。

无论如何,有一个简单的解决方法。我使用它openany只是为了表明计数器在章节中断时正确重置(实际上,它只在小节处重置)。

\documentclass[10pt,openany]{book}
\usepackage{geometry}

\usepackage[utf8]{inputenc}
\usepackage[latin]{babel}
\usepackage{sidenotes}
\usepackage[maxfloats=100]{morefloats}
\usepackage{chngcntr}

\geometry{
  marginparwidth=2cm,
}

\counterwithin*{sidenote}{subsection}
\makeatletter
\renewcommand{\thesidenote}{\@arabic{\numexpr\value{sidenote}+1\relax}}
\makeatother

\begin{document}

\chapter{Hello}

\section{Title}

\subsection{Subtitle}
Some text\sidenote{hello} that should occupy at least three lines, let's see whether 
this is enough, but probably not, so we add some words. But probably we need some
more of this boring text in order that it goes on and eventually split across three lines.
Some text\sidenote{hello} that should occupy at least three lines, let's see whether 
this is enough, but probably not, so we add some words. But probably we need some
more of this boring text in order that it goes on and eventually split across three lines.

\subsection{Subtitle}
Some text\sidenote{hello} that should occupy at least three lines, let's see whether 
this is enough, but probably not, so we add some words. But probably we need some
more of this boring text in order that it goes on and eventually split across three lines.
Some text\sidenote{hello} that should occupy at least three lines, let's see whether 
this is enough, but probably not, so we add some words. But probably we need some
more of this boring text in order that it goes on and eventually split across three lines.


\chapter{Hi}

\section{Title}

\subsection{Subtitle}
Some text\sidenote{hello} that should occupy at least three lines, let's see whether 
this is enough, but probably not, so we add some words. But probably we need some
more of this boring text in order that it goes on and eventually split across three lines.
Some text\sidenote{hello} that should occupy at least three lines, let's see whether 
this is enough, but probably not, so we add some words. But probably we need some
more of this boring text in order that it goes on and eventually split across three lines.

\subsection{Subtitle}
Some text\sidenote{hello} that should occupy at least three lines, let's see whether 
this is enough, but probably not, so we add some words. But probably we need some
more of this boring text in order that it goes on and eventually split across three lines.
Some text\sidenote{hello} that should occupy at least three lines, let's see whether 
this is enough, but probably not, so we add some words. But probably we need some
more of this boring text in order that it goes on and eventually split across three lines.

\end{document}

在此处输入图片描述

相关内容