I would like to use titlesec
to have gradient shaded section titles that extend into the left margin. I would like the section number and the gradient to extend into the left margin, but would like the section title text to be aligned with the document text.
\documentclass{article}
\usepackage{tikz}
\usepackage[nobottomtitles*]{titlesec}
\usepackage{blindtext}
\titleformat{\section}[block]%
{\Large\bfseries
\tikz[overlay] \shade[left color=black!20,right color=white] (0,-1ex) rectangle (\textwidth,1em);}%
{\thesection}%
{3em}% <---- what do I need here???
{}
\titlespacing*{\section}{-5em}{*1}{*1}
\begin{document}
\section{Here is my section title}
\blindtext
\end{document}
It seems as though I would need something like 5em-<sep>-<labelwidth>
but I don't know how to accomplish that. I would like the result to work regardless of the font or font size used.
Question: How can I, in a font independent way, have the section title text aligned with the text of the document body?
Best Answer
It is almost easier to construct the section title with the aid of
titlesec
'sexplicit
option. This allows you to use#1
as the<title>
of\section{<title>}
: