# beautiful section styles

I came across to website of IREM which I found beautiful section style in the following file Original file was created with PDFLaTeX.

Could someone please create those styles for sections and subsections with Latex

\documentclass{article}
\usepackage[utf8]{inputenc}

\title{Sections and Chapters}
\author{Educ}
\date{\today}

\begin{document}

\maketitle

\section{Plya's Problem-Solving Cycle}
\subsection{Understand the problem}
\subsection{Devise a Plan}
\subsection{Carry Out the Plan}
\subsection{Look Back}
\section{Second Section}

\end{document}

• The original file (founded by googling the file name) was created with PDFLaTeX. Probably the best thing to do is to try to contact the authors (look at the IREM website). – Kpym May 1 '18 at 8:09
• Yes, I know I took it from there, but don't forget that in this community there are many capable people who can do better than those authors. – Educ May 1 '18 at 8:17
• @Educ It would be helpful if you post the source if it's known. That saves the people time and effort and shows respect to the original author. – Dr. Manuel Kuehner May 1 '18 at 8:28
• Okay I'll do that – Educ May 1 '18 at 8:32

Answer based on titlesec and soul:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage{soul}

\definecolor{titleblue}{HTML}{4a7aa4}

\title{Sections and Chapters}
\author{Educ}
\date{\today}

\newbox\TitleUnderlineTestBox
\newcommand*\TitleUnderline[1]
{%
\bgroup
\setbox\TitleUnderlineTestBox\hbox{\colorbox{titleblue}\strut}%
\setul{\dimexpr\dp\TitleUnderlineTestBox-.3ex\relax}{.3ex}%
\ul{#1}%
\egroup
}
\newcommand*\SectionNumberBox[1]
{%
\colorbox{titleblue}
{%
\makebox[2.5em][c]
{%
\color{white}%
\strut
\csname the#1\endcsname
}%
}%
\TitleUnderline{\ \ \ }%
}
\titleformat{\section}
{\Large\bfseries\sffamily\color{titleblue}}
{\SectionNumberBox{section}}
{0pt}
{\TitleUnderline{#1}}
\titleformat{\subsection}
{\large\bfseries\sffamily\color{titleblue}}
{\SectionNumberBox{subsection}}
{0pt}
{\TitleUnderline{#1}}

\begin{document}

\maketitle

\section{Plya's Problem-Solving Cycle}
\subsection{Understand the problem}
\subsection{Devise a Plan}
\subsection{Carry Out the Plan}
\subsection{Look Back}
\section{Second Section}

\section
{Really long section name that is really long, so long it takes two rows}

\end{document}


• Could you do the same thing for subsection – Educ May 1 '18 at 8:38
• +1: I should consider soul more often :). How did you come up with \setul{.97ex}{.3ex} (the exact values)? – Dr. Manuel Kuehner May 1 '18 at 8:50
• @Dr.ManuelKuehner to be honest: trial and error. Latest edit only has .3ex as a "guessed" value (which I think looks good -- one could change that). – Skillmon May 1 '18 at 9:00
• @Dr.ManuelKuehner honesty is good for the soul – David Carlisle May 1 '18 at 10:11
• @Educ you mean in the argument of \section? Don't do that. Ever. Is that picture supposed to end up in the page's header/footer and ToC, too? – Skillmon May 1 '18 at 11:18