I am working with Overleaf. Currently, I have this:
\documentclass[12pt,a4paper,openany]{extreport}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{lipsum}
\usepackage[spanish]{babel}
\usepackage[]{geometry}
\geometry{left=2.5cm, right=2cm, top=3cm, bottom=2cm}
\addto\captionsspanish{\renewcommand{\chaptername}{\centering CAPÍTULO}}
\usepackage{titlesec}
\addto\captionsspanish{
\titleformat {\chapter}[display]{\huge\bfseries}{\chaptertitlename
\hspace{0.5ex} \thechapter}{2pt}{\large \thechapter{.} \hspace{1ex} }
\titlespacing*{\chapter}{0pt}{-26pt}{0.01cm}
}
\addto\captionsspanish{\titleformat{\section}
{\normalfont \bfseries}{\thesection}{1em}{} \titlespacing*{\section}{1cm}
{0pt}
{0pt}}
\addto\captionsspanish{\titleformat{\subsection}
{\normalfont \bfseries}{\thesubsection}{1em}{}\titlespacing*
{\subsection}
{1.25cm}{0pt}{0pt}}
\begin{document}
\chapter{Introducción}
\lipsum[4]
\section{Marco teórico}
\lipsum[4]
\subsection{tema}
\lipsum[4]
\end{document}
All the lengths and font sizes are how I need them to be. However, the text does not align with its respective heading title. I need something like this:
As you can see, the text aligns with its respective heading. I have a larger document, so if possible, I want a solution in few lines that would let me affect the whole document. Also, my document is filled with figures, equations, and tables, so if again possible, I would like a solution that wouldn't interfere much with them.



\usepackage[12pt,a4paper,openany]{extreport}should be\documentclass[12pt,a4paper,openany]{extreport}. And the titleformats also have errors in them. – Pieter van Oostrum Apr 14 '21 at 09:34--- TeX said ---