I'm trying to define a command which creates a part/chapter/section/subsection/... depending on the last defined part/chapter/section/subsection/...
It should look like this pseudo code:
global string currentSection;
function level(arg, sectioningArgs ...) {
switch(arg) {
case '+' {
switch(currentSection) {
case 'none' {
\part(sectioningArgs)
}
case 'part' {
\chapter(sectioningArgs)
}
case 'chapter' {
\section(sectioningArgs)
}
...
}
}
case '-' {
...
}
case '0' {
...
}
}
}
(just imagine a 'break' after each case ...)
The usage should be like follows:
\documentclass[a4paper,12pt,oneside]{book}
\newcommand{\level}[<?>]{<?>}
\begin{document}
\level{+}{A part}
\level{+}{A chapter}
\level{+}{A section}
\level{0}{Another section}
\level{-}{A chapter}
\level{-}{A part}
\end{document}
Rationale: I often find myself changing subsections to sections and so on in subfiles I include in my main document --- this should automate the process.
Any help is greatly appreciated, thank you in advance.

