Can you put tikzpictures into a section header?

For example, I'm trying to put the tikzpicture defined in the top rated answer of

LaTeX "under construction", "in work" or "work in progress" symbols

into my section header. The picture works fine in the main document, but as soon as I put it into a section header, I get a bunch of mysterious errors.

Below I've included some sample code that compiles. However if you replace "\section{test}" with "\section{test \WIP{0.2}}", then the desired "work in progress" symbol appears in the section header, but the compiler spits out tons of error messages I can't parse. Moreover, the symbol does not appear properly in "tableofcontents".

Are there any workarounds for this?

\usepackage[outline]{contour}% http://ctan.org/pkg/contour
\usepackage{xcolor}% http://ctan.org/pkg/xcolor

\newcommand{\WIP}[1]{\scalebox{#1}{\begin{tikzpicture}[limb/.style={line cap=round,line width=1.5mm,line join=bevel}]
\draw[line width=2mm,rounded corners,fill=yellow] (-2,0) -- (0,-2) -- (2,0) -- (0,2) -- cycle;
\fill (1.5mm,7mm) circle (1.5mm);
\fill(0,-7.5mm) -- ++(10mm,0mm) -- ++(120:2mm)--++(100:1mm)--++(150:2mm) arc (70:170:2.5mm and 1mm);
\draw[limb] (-7.5mm,-6.5mm)--++(70:4mm)--++(85:4mm) coordinate(a)--++(-45:5mm)--(-2.5mm,-6.5mm);
\fill[rotate around={45:(a)}] ([shift={(-0.5mm,0.55mm)}]a) --++(0mm,-3mm)--++
\draw[limb] ([shift={(-0.6mm,-0.4mm)}]b) --++(-120:5mm) ([shift={(-0.5mm,-0.5mm)}]c) --++
        (-3mm,0mm)--++(-100:3mm)coordinate (d);
\draw[ultra thick] (d) -- ++(-45:1.25cm);







  • 1
    Try "robustifying" \WIP with \usepackage{etoolbox}\robustify{\WIP}?
    – imnothere
    Aug 12, 2020 at 2:39
  • tex.stackexchange.com/a/463237/197451 -- Anything inside sectioning commands must be robust or protected using \protect, so you need to change you \newcommand to \DeclareRobustCommand
    – js bibra
    Aug 12, 2020 at 3:43
  • @imnothere Thank you! Robustify worked!
    – oxeimon
    Aug 12, 2020 at 5:12
  • @jsbibra Hmm \DeclareRobustCommand didn't work. Still getting errors. Though, imnothere's suggestion using \robustify did work for some reason.
    – oxeimon
    Aug 12, 2020 at 5:12
  • And what about using titlesec package?
    – vi pa
    Aug 12, 2020 at 12:45


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.