[Tex/LaTex] program that allows to move sections and automatically adjusts the level of subsections


How would one go about to move a [sub..]section to a different position in the document structure?
The sectioning commands would have to be changed according to the new parent level.
Is there a program that does that? An editor via drag and drop?
A cli call like this should do it (given that the section numbering is default):

texsectionmove main.tex 3.2 root

Best Answer

As I interpret it, None is asking for something that looks like a directory structure: we can move folders (sections/subsections...) around in an arbitrary way, and LaTeX should know whether to put \section, \subsection, or whatever else. A partial solution, that works well with copying and pasting within the document is to use a section-like environment instead of just a macro.



  \expandafter \part
  \or \expandafter \section
  \or \expandafter \subsection
  \or \expandafter \subsubsection
  \or \expandafter \paragraph
  \or \expandafter \subparagraph
    Sections are too deeply nested.%
    Trying to recover with \string\subparagraph%
  \expandafter \subparagraph


\begin{deepsection}{First section's title}  
  This text is inside the first section
  \begin{deepsection}[Short title]{And the title for a subsection}
    Some more text.
    \begin{deepsection}*{Unnumbered subsubsection}
      Yet some more text
    \begin{deepsection}{Other subsubsection}
      This subsubsection is numbered now.

\begin{deepsection}{Anoter topic}

The deepsection environment defined there takes exactly the same arguments as \section, and chooses the relevant level of sectioning for you. It will also complain if you are going deeper than you should.

Related Question