# Custom section style like this one

i see this cool section style in this question: Question

I would like to reproduce it but i don't understand how to pass section number and name to a custom tikz function. Any suggestion?

Welcome to TeX-SE! titlesec allows you to "hack" sectioning commands and to use TikZ for formatting.

\documentclass{article}
\usepackage{titlesec}
\usepackage{tikz}

\titleformat{\section}[hang]{\Large\sffamily}%
{\begin{tikzpicture}[baseline={([yshift=-1.5em]ts.north)}]
\draw[very thick,overlay] (0,0) -- (\textwidth,0);
\node[circle,fill=black,text=red,scale=2.5,anchor=west,outer sep=0pt] (ts) {\thesection};
\end{tikzpicture}}{12pt}{}%
\begin{document}
\section{Pft}
\section{Pfft}
\section{Pffft}
\end{document}


• Thank you, i really like the code style of this solution!Tonight i'm gong to study your code, did you have some good tutorial about that? – Jaeger Jun 11 at 17:06
• @Jaeger You're welcome! – user121799 Jun 11 at 17:06

A solution with pstricks:

\documentclass[svgnames]{article}
\usepackage{lipsum}
\usepackage{pstricks}
\usepackage{linegoal}
\usepackage{titlesec}

\titleformat{\section}[hang]{\sffamily}%
{\pscirclebox*[linecolor=DarkSlateGrey, fillcolor=DarkSlateGrey, framesep=14pt]{\Huge\textcolor{red}{\thesection}}%
\rlap{\color{DarkSlateGrey}\rule[6pt]{\linegoal}{1pt}}}%
{12pt}%
{\Large \color{DarkSlateGrey}\raisebox{12pt}}

\titlespacing*{\section}{0pt}{3mm}{5mm}

\begin{document}

\setcounter{section}{4}

\section{Discussion}
\lipsum[1]

\end{document}