Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there another way of doing this besides doing a manual find "section"/ replace all with "chapter" (and the same for subsections, subsubsections etc.) ?

share|improve this question

4 Answers 4

The timing of actions is crucial if all levels must be promoted: we have to start from the lowest level up and use \let.


Using \renewcommand would turn all section levels into chapters.

However this can work only for very elementary documents without cross references. A complete solution should redefine also the counters and their representation.


share|improve this answer
But is that the correct thing to do? I know this works, but it does not 'feel right'. I would much favor replacements done in an editor. –  Taco Hoekwater Jul 28 '11 at 9:10
No, it isn't the "correct" way to do it. Also all the related macros have to be changed. –  egreg Jul 28 '11 at 9:16
@Taco I've supplemented the macros; using a "find and replace" starting from \section downward would certainly be better. –  egreg Jul 28 '11 at 9:28
@egreg there is a small typo I cannot edit: \let\theparagraph\the\subsubsection should be \let\theparagraph\thesubsubsection –  Tobias Aug 5 '13 at 19:21

Besides replacing/redefining the sectioning commands as noted in the other answers, one thing to remember is also updating the reference descriptions when using \ref. If your text reads

As seen in Section \ref{sec:first}, ...

after conversion to a report it should become

As seen in Chapter \ref{sec:first}, ...

If you consistently use the cleveref package's \cref command, this is a non-issue:

As seen in \cref{sec:first}, ...

The command infers the type of the reference from the label and places a textual description in front of the actual section/chapter number. I really see no reason not to use this package.

share|improve this answer

Here is a unix script that gives you the option to shift things outward (i.e. for article to report) or inward (report to article, or beamer).


if [ $# -lt 2 ]
        echo "need input file name, 0 (out) or 1 (in) " >&2
        exit 1
# strips .tex from filename to append _out.tex or _in.tex

# 0 shifts all headings outward (section->chapter, etc)
# 1 shifts all headings outward (chapter->section)
if [ $2 -eq 0 ]
        sed -e 's/\\section{/\\chapter{/g' \
            -e 's/\\subsection{/\\section{/g' \
            -e 's/\\subsubsection{/\\subsection{/g' \
            -e 's/\\paragraph{/\\subsubsection{/g' \
            -e 's/\\subparagraph{/\\paragraph{/g' \
            "$1" > $newfile

         echo "Saved as $newfile"
elif [ $2 -eq 1 ]
        sed -e 's/\\paragraph{/\\subparagraph{/g' \
            -e 's/\\subsubsection{/\\paragraph{/g' \
            -e 's/\\subsection{/\\subsubsection{/g' \
            -e 's/\\section{/\\subsection{/g' \
            -e 's/\\chapter{/\\section{/g' \
            -e 's/Chapter /\\S/g' \
            -e 's/Chapters /\\S/g' \
            -e 's/chapter/section/g' \
            "$1" > $newfile

        echo "Saved as $newfile"
        echo "invalid direction, 0 (out) or 1 (in) " >&2
share|improve this answer
Nice one! Please note also the -i switch of sed, for in-place replacement. –  krlmlr Jul 12 '13 at 0:25

I might be a bit overkill, but I would use sed for that instead of pure TeX.

share|improve this answer
Every good editor sports a "find and replace all" feature. One has only to be careful and start from the top: \section to \chapter, then \subsection to \section and so on. Also with sed multiple passes are needed. –  egreg Jul 28 '11 at 10:30
Using Texlipse, I ended up doing this as well. –  ptikobj Jul 28 '11 at 12:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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