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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am preparing a non-technical document and would like to add some spice to it. Doing so, I'm trying to redefine the section command that is provided by the KOMA Script classes.

My idea is that it should look something like this:


Since this is the first time that I am doing something like this, I am struggling. My philosophy is that the code does not need to be perfect, as long as it just works. I've been looking at some other code to get some inspiration but some things I can not figure out.

Here is how I am trying to tackle it:

  • Use TikZ to draw the shape
  • Copy paste the section command provided by the KOMA classes into \renewcommand and alter it there
  • Use \ifodd\value{page} ..then.. \else \fi to check for even/odd pages and adjust parameters accordingly
  • Use \hspace to move the arrow into the margin

Here is what I have come up with:



\definecolor{visgreen}{rgb}{0.733, 0.776, 0}

  {-3.5ex \@plus -1ex \@minus -.2ex}%
  {2.3ex \@plus.2ex}%
  {\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
        \begin{tikzpicture}[auto, font=\Huge, every node/.style={signal, draw, text=white, signal to=nowhere}]
            \node[visgreen, fill, signal to=east, inner sep=1em, drop shadow, text=white] at (0,0) {\raggedsection\normalfont\sectfont\nobreak\size@section};
        \begin{tikzpicture}[auto, font=\Huge, every node/.style={signal, draw, text=white, signal to=nowhere}]
        \node[visgreen, fill, signal to=west, inner sep=1em, drop shadow, text=white] at (0,0) {\raggedsection\normalfont\sectfont\nobreak\size@section};


\section{Second Test}


Unfortunately, there are a few problems that I can not solve:

  • \oddsidemargin+1in is apprently not enough to move the arrow up to the page border
  • \hspace does not work at all on even pages
  • For some reason, the section name and number do not show up in the arrow, but next to it

Currently it looks like this (on an odd page):

enter image description here

It would be great if you could give me some hints how I can fix these issues. If I manage to solve the problem I might delve deeper into the matter and write some more fancy section titles and pacakge them.

share|improve this question
Do the sections have a title or just a number? – Marco Apr 10 '12 at 18:21
Title and number. But in fact I haven't seen that question yet. I'll give that approach a shot :). – Ingo Apr 10 '12 at 18:44
The problem is that I can not put the section title into the node, but the signal shape is provided by a node. No idea how to tackle this using TikZ :-/. No idea whether the section title is accessible through any command at all, something like \sectiontitle does not exist. – Ingo Apr 10 '12 at 19:44
@tehingo: you can use the explicit option for titlesec, as I did in my answer. – Gonzalo Medina Apr 10 '12 at 19:57
up vote 7 down vote accepted

Here's a quick solution, to be used as a starting point (it admits improvements), using the titlesec package:


\definecolor{visgreen}{rgb}{0.733, 0.776, 0}

% the tikz picture that will be used for the title formatting
% \SecTitle{<signal direction>}{<node anchor>}{<node horiz, shift>}{<node x position>}{#5}
% the fifth argument will be used by \titleformat to write the section title using #1
\begin{tikzpicture}[overlay,every node/.style={signal, draw, text=white, signal to=nowhere}]
  \node[visgreen,fill, signal to=#1, inner sep=1em, drop shadow,
    at (#4,0) {#5};




\section{Test Section One}
\section{Test Section Two}
\section{Test Section Three}
\section{Test Section Four}


enter image description here

share|improve this answer
Great work Gonzalo Medina. There is one obvious problem :) The automatic numbering of sections, however, does not get passed to the tikz environment. Do you have any ideas how I might do that? – macmadness86 Jul 4 '12 at 23:27

Here is a quick ConTeXt solution that can get you started. It still lacks several features, e.g. the section number is not converted to a text string and there's no distinction between even and odd pages. The spacing around the “arrow background” and the background itself could be optimized and the hard coded horizontal space should vanish.

\definecolor [chapcolour] [h=bbc600]
\setuphead   [section]    [command=\myseccmd]

        ]{Section #1}}

    path p; path q;
    p := origin -- (0cm,\overlayheight) -- (\overlayheight/2,\overlayheight/2) -- cycle;
    q := origin -- (\overlaywidth,0cm) -- (\overlaywidth+\overlayheight/2,\overlayheight/2);
    fill unitsquare xyscaled (\overlaywidth,\overlayheight) withcolor \MPcolor{chapcolour};
    fill p xshifted \overlaywidth withcolor \MPcolor{chapcolour};
    interim linecap := butt;
    draw q withpen pencircle scaled 2pt withcolor \MPcolor{darkgray};
    setbounds currentpicture to unitsquare xyscaled (\overlaywidth, \overlayheight);

\defineoverlay [chap] [\useMPgraphic{chap}]

    \startsection [title=Foo]
        \input ward
    \startsection [title=Bar]
        \input knuth


It uses MetaPost, instead of Tikz. First I create a custom section command which uses a \framed-frame to easily include a background. Then I create a MetaPost graphic and use this graphic as an overlay, whichis included as a background behind the section titles.

share|improve this answer

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.