newinclude(仍然)是一個很好用的包嗎?

newinclude(仍然)是一個很好用的包嗎?

我在嘗試將程式碼組織成幾個節檔案以加快期刊論文的編譯速度時想出了這個 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 指令包含多個檔案時出現交叉引用問題帶有包含文件和輕鬆清晰頁面的參考標籤, 尤其,這個答案

現在,看看上面的問題以及使用“\let\clearpage\relax”關閉 LaTeX 中的“\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}

相關內容