輸入文件時如何自動降低章節標題?

輸入文件時如何自動降低章節標題?

我想知道在將文件 via 輸入到另一個文件時是否有一種方法告訴 (Xe)LaTeX 處理\chapteras \section\sectionas等。\subsection\input

設定是:我有一個帶有最少 LaTeX 標記的文字。我需要在兩個不同的環境/兩個不同的根文件中使用此文字。

一個生成了我需要大標題的文本的“獨立”版本,另一個是引用該文本的論文,我需要降低標題,因為它是\chapter.有任何想法嗎?


文字檔案“text.tex”

\chapter*{Introduction}
Bla Bla
\section*{Point 1}
...

根檔案#1:

\begin{document}
\input{text}
\end{document}

根檔案#2:

\begin{document}
\chapter{First ideas to my text}
...
\chapter{My way to my text}
...
\chapter{The final text}
\input{text}
\end{document}

答案1

一個快速的嘗試,但我必須考慮編號

\documentclass{book}



\usepackage{etoolbox}

\let\latexchapter\chapter
\let\latexsection\section

\newcommand{\OneLevelDeeper}{%
  \let\chapter\section
  \let\section\subsection
}

\begin{document}
\tableofcontents

\chapter{First}
\section{Section}
\subsection{Subsection}

\OneLevelDeeper
\chapter{First Fake}
\section{Section Fake}
\subsection{Subsection Fake}


\end{document}

相關內容