For a bigger writing project of article type book, I would like to color the heading and the text of certain sections, subsections, and subsubsections in different colors.

  • Normal text is as usual in black (commands section, subsection, subsection)
  • Text and heading of what I wrote very recently should be red (e.g. via new commands sectionNew, subsectionNew, ...)
  • Text and heading of what has already been corrected several times and is approved by a native speaker I would like to display in green (e.g. sectionFinished, subsectionFinshed, etc.)

I can define the commands of the new sections like this



One way to get the behavior I desire is to add { and } around the section[New|Finished] commands I defined and the following text.

     Lorem ipsum.

However, I would like to avoid this if possible, as the curly brackets IMHO make the text less readable in the LaTeX file.

Without the curly brackets, the above mentioned has the problem that all subsequent sections without a specific definition are colored red or green as well (until encountering another explicit color statement). I think maybe renewing the section command with explicitly defining black as the color could be the solution. Unfortunately, I can not figure out how to renew the section command in a generic way (taking over everything from the document type except an explicit color statement).

Is there any solution to this?

Or maybe is there a package that does this already for me (i.e. a kind of text management/versioning inside the latex document)?

UPDATE: One drawback of this is that it is not possible to use an alternative title for the page headings anymore (\section[Alt Title for Heading]{Normal Title}).

  • You could add \leavevmode: \newcommand\sectionNew[1]{\section{\color{red}#1}\color{red}\leavevmode} \newcommand\sectionFinished[1]{\color{green}\section{#1}\color{green}\leavevmode}. But do you really want to do that?
    – user121799
    Commented Sep 4, 2018 at 14:05
  • @marmot: Thanks for your answer! However, it seems that it does not change anything in my case. Should it?
    – Exocom
    Commented Sep 4, 2018 at 18:21

2 Answers 2


You can use environments instead of commands for sectioning:









enter image description here


After tinkering around a bit more, I think I found a solution:


Unfortunately, convincing chapter to work similarly is a bit more complicated, but can be achieved like this (solution is from here):


The only thing that could be improved is the section numbering, as this does not change color. However, this does not affect the functionality in my case and I can live with that.

You must log in to answer this question.

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