I would include a new \titleformat wherever I want a new title format to start... The \titleformat should act like a switch (similar to a font changing macro like \bfseries or \itshape), changing formatting from that point onward; so there's technically no "conditioning" required. A bigger question though: Why do you want to switch formats and not keep things consistent?
–
WernerApr 5 '14 at 6:27

@How do I define other formats with \titleformat? For the bigger question, in fact I want to keep the same "global idea" but I want to change things like the "Chapter" word and the color of the node.
–
VincentApr 5 '14 at 6:36

You could have a look on the titlesec package (the documentation contains some examples) or using the KOMA classes in order to change the titleformat.
–
SoundsOfSilenceApr 5 '14 at 6:52

What do you mean by saying "appendix in mainmatter"? There is a \appendix switch to be used to create appendecies. Shouldn't your third requirement be "chapter in appendix"?
–
RubenApr 5 '14 at 8:32

1 Answer
1

Generally speaking, rather than including "conditionals" in the title format to work out where in the document the title is used, you either (a) include macros in the format itself which will expand appropriately (e.g. \chaptertitlename which will be redefined once \appendix is given) or (b) redefine with a new \titleformat at the appropriate point in the document.

Since you didn't give a complete compilable MWE I'm guessing somewhat about your settings. But here's a short example. This is basically your code, but (a) instead of "hardcoding" the word "Chapter" in the bit that prints the colored box, I've used \chaptertitlename and (b) instead of hard-coding a color in the two places you used it, I put a macro which can therefore easily be redefined.