I would like my document to have section headings that look like this:
How can I achieve this in LaTeX?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityFor your final solution define the dark red color as desired and replace it with 'red' in my proposal. Note that in the below example the given design is also apllied to the section format.
\documentclass[11pt]{article}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\Large\itshape\color{red}}{%
\hspace*{-4.5em}\rule[-1.35mm]{4.5em}{1.25em}
{\color{white}\hspace{-1cm}\normalfont\thesection\hspace{5pt}}
}{1em}{}
\titleformat{\subsection}
{\normalfont\large\itshape\color{red}}{%
\hspace*{-4.5em}\rule[-1.35mm]{4.5em}{1.25em}
{\color{white}\hspace{-1cm}\normalfont\thesubsection\hspace{5pt}}
}{1em}{}
\begin{document}
\section{Introduction}
\lipsum[1]
\subsection{Laplace Transformation}
\lipsum[2-4]
\end{document}