2

This question already has an answer here:

I'm wondering if there's a way to tell (Xe)LaTeX to handle \chapter as \section, \section as \subsection and so on when inputting a document via \input into another document.

The setting is: I have a text with minimal LaTeX Markup. I need to use this text in two different environments / two different root files.

One produces my "standalone" Version of this text where I need big headings and the other one is a thesis referring to this text where I need to level-down the headings, because it's part of a \chapter. Any ideas?


text file "text.tex"

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

root file #1:

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

root file #2:

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

marked as duplicate by Andrew, user13907, Svend Tveskæg, darthbith, T. Verron Apr 24 '15 at 13:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    This should be possible. Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Apr 24 '15 at 11:56
  • Related: tex.stackexchange.com/questions/26181/… – musarithmia Apr 24 '15 at 12:10
  • Thank you @egreg for pointing this out, i didn't find that. – Johannes Heck Apr 24 '15 at 12:56
2

A quick trial, but I have to think about the numbering

\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}
  • You might also want a \OneLevelHigher or, better still, to wrap this into an environment. – Andrew Apr 24 '15 at 12:03
  • @Andrew: Yes, but I saw, it's a duplicate ... I will come to it later on, perhaps showing another approach – user31729 Apr 24 '15 at 12:09
  • @Andrew there is no need, just grouping does the job. – touhami Apr 24 '15 at 13:11
  • 1
    @touhami Of course, but environments are how one does grouping in latex. – Andrew Apr 24 '15 at 14:03
  • Thanks for your very fast answer, @ChristianHupfer, I'll think it's the same approach as suggested in the dublicate thread under link that I didn't find due to my small english vocabulary. – Johannes Heck Apr 24 '15 at 15:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.