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
  • 3
    Sections only receive their numbers when the document is compiled, so there is no coherent sense of "section 3.2" in your source document. If you want to move a section, just move it and the number will change automatically. If you want a subsection to become a section, you just need to remove the 'sub' from the \subsection command.
    – Alan Munn
    Jan 15, 2011 at 16:30
  • I think what None wants is to move \subsection{blah} hjkj \subsubsection{bloh} hjkh \subsubsection{blih} to \section{blah} hjkj \subsection{bloh} hjkh \subsection{blih}. I would do that with some regular expression substitution. Jan 15, 2011 at 19:51
  • I can't remember, but I am pretty sure org-mode can do this. Maybe using it and only then exporting to LaTeX is a good idea?
    – mbork
    Jul 1, 2012 at 17:05
  • @mbork for the record, org-mode can do this. I'm surprised that RefTeX doesn't (seem to), though. Jul 9, 2015 at 14:04

6 Answers 6


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.

  • Also see github.com/wspr/newsec . This type of thing comes up just often enough I think there's some merit in providing a maintained interface for it. That code is just experimentation, though. Jul 1, 2012 at 14:00

The question, as it stands, could be asking two different things. One: "Let's say I want to make all my sections into subsections and knock every other structure command down a level too" This could be done with a little regex-fu, for example, with sed. The idea would be to just find and replace all instances of each structure command with the next lowest. You'd have to start at the bottom and go up. So let's say the lowest structure command you have is \subsubsection and you want to knock this down to \paragraph. So run each of these lines in a terminal:

sed s/'\\subsubsection{'/'\\paragraph{'/ file.tex
sed s/'\\subsection{'/'\\subsubsection{'/ file.tex

and so on. This could obviously be improved loads by running them all with one script, and the like, but you get the idea.

The other thing this question might be asking is "I want to move a whole section of text around within a document AND change its level. This isn't as easy. emacs auctex mode has a command for marking a whole section: C-c * and then you can cut it with C-w as per usual. Automatically having the section change its section level is harder, but then it's not clear it would be useful. Sometimes you want a section to stay a section when you move it, and sometimes you want it to become a subsection. So it's best to do that by hand. With emacs reftex you can do this by moving to the section of interest in the reftex menu and using C-< or C-> to move up or down a level respectively.


You can easily move and demote or promote a selection that includes sections and subsections in Lyx. The shortcut is Alt-P and then one of the arrow keys - left and right promote or demote and up and down to move the selection.


In TexStudio you can use the "structure" view which will open a window with the outline of you Latex document. [Click on "View" in the menu bar or press ALT then V.]

You can right-click any section, copy or cut it an paste it somewhere else. All the content between the cut and the subsequent subsection will be moved.

You can also indent or unident sections, which means that you can change subsections to sections and vice versa.

The question is really old, but I hope this might help anybody who, like me found this question using Google.

  • 1
    It's not MiKTeX that you're talking about. Take a read through my article on TeX terminology. What are you using as your editor? Jul 9, 2015 at 13:58
  • Yeah, you're right. The Tex world is confusing for beginners. I guess TexStudio is my editor then.
    – Malo
    Jul 10, 2015 at 14:39
  • You should edit your answer appropriately, then :) Jul 10, 2015 at 14:40
  • Right, good idea. I'm new to stackexchange, but I already love this place. Finally there's a place that gets rid of all the downsides of searching for information in forums :)
    – Malo
    Jul 10, 2015 at 14:43
  • It's a pretty nice system, and very nice people on this site in particular. Drop by the chatroom some day and say hi :) Jul 10, 2015 at 14:44

I understand the original question as: how can I convert section A to a chapter and at the same time automatically convert all sub-sections of section A to sections, all subsubsections to subsections etc

In TexmakerX that should be possible, however I admit that I did not try it yet:

In the structure view which shows the sections of the document like a tree, you can use the context menu to indent or de-indent a section (and afaik) that should also "move" all the sub-sections of that section 1 level up or down.


My understanding of the question, based on its comments, is that the asker would like to be able to shift the depth of sections (and their subsections), as in MostlyHarmless's answer.

The emacs reftex mode provides a table of contents buffer that lets you promote/demote sections. You can access it by going either M-x reftex-toc or C-c =. After selecting the sections you would like to shift, you can then promote them with < and demote them with >.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .