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:
\documentclass{scrbook}
\usepackage{tikz,ifthen,blindtext}
\usetikzlibrary{shapes.symbols,shadows}
\definecolor{visgreen}{rgb}{0.733, 0.776, 0}
\makeatletter
\renewcommand\section{\@startsection{section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\ifnum \scr@compatibility>\@nameuse{scr@[email protected]}\relax
\setlength{\parfillskip}{\z@ plus 1fil}\fi
\ifodd\value{page}
\hspace*{-\dimexpr\oddsidemargin+1in\relax}
\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};
\end{tikzpicture}
\else
\hspace*{\dimexpr\evensidemargin+1in\relax}
\begin{flushright}
\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};
\end{tikzpicture}
\end{flushright}
\fi}%
}
\makeatother
\begin{document}
\section{Test}
\Blindtext
\section{Second Test}
\blindtext
\end{document}
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):
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.
:)
.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.explicit
option fortitlesec
, as I did in my answer.