0

I want to adjust the title indentation for all the section and subsection titles as shown in the image. How can I achieve this using the titlesec or other similar packages?

This is a minimal version of my current code.

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}

[...]

\usepackage{geometry}
\geometry{
a4paper,
left=3.5cm,
right=2cm,
top=3.5cm,
bottom=2cm
}

[...]

\begin{document}
\section{Introduction}
\subsection{Background}
\subsubsection{Machine Reading Comprehension (MRC)}
MRC is a subfield.........

[...]
    

\end{document}

What I want: enter image description here

What I have: enter image description here

I am using a documentclass{report} and my section titles are in the left edge of the paper by default. But I would like to indent them 3.5mm from the left edge of the paper as shown in the above image.

6
  • Does this answer your question? How to left align the section title in latex?
    – Roland
    Feb 25 '21 at 6:31
  • No. I am using a documentclass{report}, and my section titles are already aligned to the left side of the paper. But I would like to indent them 3.5mm from the left edge of the paper.
    – Raavan
    Feb 25 '21 at 6:35
  • Well would you like to paste an minimal working example? Let us know how you align title left?
    – Syvshc
    Feb 25 '21 at 7:01
  • @ Raavan. This is important information that you should have given from the beginning. Maybe you should read first How to ask a question and provide a MWE.
    – Roland
    Feb 25 '21 at 7:02
  • @Raavan please see if the answer meets the requirement -- as amended from the solution given here -- tex.stackexchange.com/questions/25082/…
    – js bibra
    Feb 25 '21 at 7:10
1

Welcome to TEX.SE! I use titlesec package to meet this requirement.

\documentclass{report}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage[showframe]{geometry}
\geometry{
a4paper,
left=3.5cm,
right=2cm,
top=3.5cm,
bottom=2cm
}

\titleformat{\chapter}{\normalfont\huge\bfseries}{\thechapter .}{3.5mm}{}
\titlespacing*{\chapter}{3.5mm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titleformat{\section}{\normalfont\Large\bfseries}{\thesection .}{3.5mm}{}
\titlespacing*{\section}{3.5mm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titleformat{\subsection}{\normalfont\large\bfseries}{\thesubsection .}{3.5mm}{}
\titlespacing*{\subsection}{3.5mm}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\begin{document}
    \chapter{Introduction}
    \section{Background}
    \subsection{Machine Reading}
    \lipsum[1]
\end{document}

enter image description here

I got the length value from texdoc titlesec sec 9.2 "Standard Classes".

1
  • This worked! Thanks!
    – Raavan
    Feb 25 '21 at 7:30
1

enter image description here

\documentclass{article}
\usepackage{titlesec}
%1inch=25,4mm
\titlelabel{{\hspace*{1cm}\makebox[1cm][l]{\thetitle}}}
%\usepackage{indentfirst}
\usepackage{lipsum}
\usepackage{showframe}
\begin{document}
    \section{foo}
    \hspace*{25.4mm}\lipsum[1]
    \section{bar}
    \subsection{foo bar}
    \lipsum[1]
\end{document}

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.