newclude 仍然是一个很好的软件包吗?

newclude 仍然是一个很好的软件包吗?

我在尝试将我的代码组织成几个部分文件以加快期刊论文的编写速度时想到了这个 MWE(sections,不是chapters!):

\documentclass{article}
\usepackage{filecontents}
%\usepackage{newclude}
\begin{filecontents}{\jobname-ext.tex}
    \section{A section}
    \label{sec:A}
    References to this section \ref{sec:A} do not work.
\end{filecontents}
\begin{document}
    \begingroup
    \let\clearpage\relax
    \include{\jobname-ext}
    \endgroup

    \section{Another section}
    No page break after section \ref{sec:A}, please!
\end{document}

令人惊讶的是(一开始),结果缺乏正确的引用。看到使用 include t命令包含多个文件时出现交叉引用问题带有包含文件和轻松清除页的参考标签, 尤其,这个答案

现在,看看上面的问题以及在 LaTeX 中使用“\let\clearpage\relax”关闭“\clearpage”后重新激活“\clearpage”,没有一个答案或评论(或问题)提到该newclude软件包,它提供了一个\include*不发出\clearpage。我想知道这是否是一个可以使用的软件包,因为它尚未更新自 1999 年起

这是另一段无需重新定义即可运行的代码\clearpage

\documentclass{article}
\usepackage{filecontents}
\usepackage{newclude}
\begin{filecontents}{\jobname-ext.tex}
    \section{A section}
    \label{sec:A}
    References to this section \ref{sec:A} DO work.
\end{filecontents}
\begin{document}
    \include*{\jobname-ext}

    \section{Another section}
    No page break after section \ref{sec:A}, please!
\end{document}

以下还有另外两个不符合要求的:

\documentclass{article}
\makeatletter
\def\include#1{\relax
  \ifnum\@auxout=\@partaux
    \@latex@error{\string\include\space cannot be nested}\@eha
  \else \@include#1 \fi}
\def\@include#1 {%
  %\clearpage
  \if@filesw
    \immediate\write\@mainaux{\string\@input{#1.aux}}%
  \fi
  \@tempswatrue
  \if@partsw
    \@tempswafalse
    \edef\reserved@b{#1}%
    \@for\reserved@a:=\@partlist\do
      {\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
  \fi
  \if@tempswa
    \let\@auxout\@partaux
    \if@filesw
      \immediate\openout\@partaux #1.aux
      \immediate\write\@partaux{\relax}%
    \fi
    \@input@{#1.tex}%
    %\clearpage
    \@writeckpt{#1}%
    \if@filesw
      \immediate\closeout\@partaux
    \fi
  \else
    \deadcycles\z@
    \@nameuse{cp@#1}%
  \fi
  \let\@auxout\@mainaux}
\makeatother
\usepackage{filecontents}
\begin{filecontents}{\jobname-ext.tex}
    \section{A section}
    \label{sec:A}
    References to this section \ref{sec:A} do not work.
\end{filecontents}
\begin{document}
    \include{\jobname-ext}

    \section{Another section}
    No page break after section \ref{sec:A}, please!
\end{document}

\documentclass{article}
\usepackage{xpatch}
\makeatletter
\patchcmd{\@include}{\clearpage}{}{}{error}
\patchcmd{\@include}{\clearpage}{}{}{error}
\makeatother
\usepackage{filecontents}
\begin{filecontents}{\jobname-ext.tex}
    \section{A section}
    \label{sec:A}
    References to this section \ref{sec:A} do not work.
\end{filecontents}
\begin{document}
    \include{\jobname-ext}

    \section{Another section}
    No page break after section \ref{sec:A}, please!
\end{document}

相关内容