使用 \marginnote 时的页码对齐

使用 \marginnote 时的页码对齐

请参阅 MWE。我希望页码与整个文本块(文本 + 边注)对齐,如第 3 页。我知道这是可能的,因为它在 Notes Tex 的文档中使用(https://ctan.math.washington.edu/tex-archive/macros/latex/contrib/notestex/doc/NotesTeX.pdf),却找不到办法!

\documentclass[10pt]{book}
\usepackage{lipsum}
\usepackage{marginnote}
 \renewcommand*{\marginfont}{\scriptsize \sffamily}
   \renewcommand\raggedrightmarginnote{}
\renewcommand\raggedleftmarginnote{}


\usepackage[
paperwidth=160mm, paperheight=240mm,
textheight=18cm,
textwidth=8cm,
inner=2cm, marginparwidth=2.5cm, marginparsep=0.5cm]
    {geometry}
\usepackage{wrapfig}
\usepackage{fontspec}
\begin{document}
%\sloppy


\newpage

\paragraph{First}
\begin{wrapfigure}{i}{0.64\textwidth}%
  \vspace{5pt}
  \noindent  {\fontsize{46pt}{46pt}\selectfont \hspace{-5pt}  Big}
  \end{wrapfigure}
This\marginnote{I want this to be aligned. \lipsum[1]} is a paragraph. \lipsum[1]

\newpage

\paragraph{First}
\begin{wrapfigure}{i}{0.64\textwidth}%
  \vspace{5pt}
  \noindent  {\fontsize{46pt}{46pt}\selectfont \hspace{-5pt}  Big}
  \end{wrapfigure}
This\marginnote{I want this to be aligned. \lipsum[1]} is a paragraph. \lipsum[1]

\newgeometry{
textwidth=11cm}
\lipsum[1]
\restoregeometry

\end{document}

答案1

这用来\AddToHook实现页码。

\documentclass[10pt]{book}
\usepackage{lipsum}
\usepackage{marginnote}
 \renewcommand*{\marginfont}{\scriptsize \sffamily}
   \renewcommand\raggedrightmarginnote{}
\renewcommand\raggedleftmarginnote{}

\usepackage[
paperwidth=160mm, paperheight=240mm,
textheight=18cm,
textwidth=8cm,
inner=2cm, marginparwidth=2.5cm, marginparsep=0.5cm, showframe]
    {geometry}
    
\pagestyle{empty}
\AddToHook{shipout/background}{\ifodd\value{page}
  \put (\dimexpr 1in+\oddsidemargin+\textwidth+\marginparsep+\marginparwidth\relax, \dimexpr -1in-\topmargin-\headheight\relax)
    {\llap{\thepage}}% right justified
\else
  \put (\dimexpr 1in+\evensidemargin-\marginparsep-\marginparwidth\relax, \dimexpr -1in-\topmargin-\headheight\relax)
    {\thepage}
\fi}

  
  
\usepackage{wrapfig}
\usepackage{fontspec}
\begin{document}
\newpage

\paragraph{First}
\begin{wrapfigure}{i}{0.64\textwidth}%
  \vspace{5pt}
  \noindent  {\fontsize{46pt}{46pt}\selectfont \hspace{-5pt}  Big}
  \end{wrapfigure}
This\marginnote{I want this to be aligned. \lipsum[1]} is a paragraph. \lipsum[1]

\newpage

\paragraph{First}
\begin{wrapfigure}{i}{0.64\textwidth}%
  \vspace{5pt}
  \noindent  {\fontsize{46pt}{46pt}\selectfont \hspace{-5pt}  Big}
  \end{wrapfigure}
This\marginnote{I want this to be aligned. \lipsum[1]} is a paragraph. \lipsum[1]

\newgeometry{marginparsep=0pt, marginparwidth=0pt, textwidth=11cm}
\lipsum[1]
\restoregeometry

\end{document}

这将\pagestyle{headings}修改应该是书籍类的默认样式。

\documentclass[10pt]{book}
\usepackage{lipsum}
\usepackage{marginnote}
 \renewcommand*{\marginfont}{\scriptsize \sffamily}
   \renewcommand\raggedrightmarginnote{}
\renewcommand\raggedleftmarginnote{}

\usepackage[
paperwidth=160mm, paperheight=240mm,
textheight=18cm,
textwidth=8cm,
inner=2cm, marginparwidth=2.5cm, marginparsep=0.5cm, showframe]
    {geometry}
    
\makeatletter
\def\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\hskip\dimexpr -\marginparsep-\marginparwidth\relax \thepage\hfil\slshape\leftmark}%
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage\hskip\dimexpr -\marginparsep-\marginparwidth\relax}%
      \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markboth {\MakeUppercase{%
        \ifnum \c@secnumdepth >\m@ne
          \if@mainmatter
            \@chapapp\ \thechapter. \ %
          \fi
        \fi
        ##1}}{}}%
    \def\sectionmark##1{%
      \markright {\MakeUppercase{%
        \ifnum \c@secnumdepth >\z@
          \thesection. \ %
        \fi
        ##1}}}}
\makeatother
\pagestyle{headings}
  
\usepackage{wrapfig}
\usepackage{fontspec}
\begin{document}
\newpage

\paragraph{First}
\begin{wrapfigure}{i}{0.64\textwidth}%
  \vspace{5pt}
  \noindent  {\fontsize{46pt}{46pt}\selectfont \hspace{-5pt}  Big}
  \end{wrapfigure}
This\marginnote{I want this to be aligned. \lipsum[1]} is a paragraph. \lipsum[1]

\newpage

\paragraph{First}
\begin{wrapfigure}{i}{0.64\textwidth}%
  \vspace{5pt}
  \noindent  {\fontsize{46pt}{46pt}\selectfont \hspace{-5pt}  Big}
  \end{wrapfigure}
This\marginnote{I want this to be aligned. \lipsum[1]} is a paragraph. \lipsum[1]

\newgeometry{marginparsep=0pt, marginparwidth=0pt,textwidth=11cm}
\lipsum[1]
\restoregeometry

\end{document}

相关内容