1

i see this cool section style in this question: Question

The cool style

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?

0

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}

enter image description here

  • 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
0

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} 

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.