Basically, I need to indent paragraphs after a subsection as shown here:


Basically, I need to indent the all the content after a subsection. I already have the proper formatting for the heading of the subsection as follows:


I found a solution here: Indenting a whole paragraph

However, the problem is that in order to apply the solution I will need to manually add code before and after each subsection.

Another solution here: Indent every \subsubsection element

proposes using a new environment:


\subsection{A subsection}







However, this has the same problem: I would need to manually add \begin...\end of the environment for each subsection I have. Is there a better solution?

  • 2
    Automation of this is hard to do because the sectioning commands are not environments (an unfortunate design choice in some ways). So as a result, you can't hook into the end of a section/subsection etc. which is what you would need to have this work.
    – Alan Munn
    Jan 29, 2019 at 19:19

1 Answer 1


In the same spirit as your first quoted answer and using etoolbox's patchcmd you can assume that \leftskip is not used dor anything else, the magic is :

\patchcmd{\subsection}{-3.25ex\@plus -1ex \@minus -.2ex}{3.25ex\@plus -1ex \@minus -.2ex\setlength{\leftskip}{0cm}}{}{}
\patchcmd{\subsection}{1.5ex \@plus .2ex}{1.5ex \@plus .2ex\setlength{\leftskip}{2cm}}{}{}
\patchcmd{\section}{-3.5ex \@plus -1ex \@minus -.2ex}{-3.5ex \@plus -1ex \@minus -.2ex\setlength{\leftskip}{0cm}}{}{}

which switches off the shift at the beginning of the \section and \subsection, and switches it on when entering into \subsection. Here is a MWE, in the which I changed the page size to fit the example on two pages:


\patchcmd{\section}{-3.5ex \@plus -1ex \@minus -.2ex}{-3.5ex \@plus -1ex \@minus -.2ex\setlength{\leftskip}{0cm}}{}{}
\patchcmd{\subsection}{-3.25ex\@plus -1ex \@minus -.2ex}{3.25ex\@plus -1ex \@minus -.2ex\setlength{\leftskip}{0cm}}{}{}
\patchcmd{\subsection}{1.5ex \@plus .2ex}{1.5ex \@plus .2ex\setlength{\leftskip}{2cm}}{}{}
\section{Section Foo}
\subsection{A subsection}\label{s:first}
\subsection{Another subsection}

\section{Section Bar}
\textbf{As seen in section \ref{s:first}}
\subsection{Test again}

with the result: enter image description here

Note 1: this works also with hyperref, provided you make the patch before loading it.

Note 2: This approach is likely not compatible with titlesec. It assumes that the sectioning commands (below \chapter) are based on the standard \@startsection command. This is not an issue as you can also patch in a similar way the format of the title for getting italic

Note 3: To determine the value of the second argument of \patchcmd (which depends on the class and ptsize) you have to look at the content of the sectionng commands. For this purpose I use a custom command :

\newcommand{\mymeaning}[1]{{\small\noindent{\bfseries \string #1} = \meaning #1\par\medskip}}

based on the standard command \meaning with some cosmetic, and do e.g. \mymeaning{\subsection} in the document.

  • 1
    If you have chapters or part, ending a subsection you would have to apply to the corresponding command the same patch as for section, disabling the shift. I will soon provide the patch for the standard \chapter. An other option (for chaoter) would be to alter the clearpage command.
    – Jhor
    Jan 31, 2019 at 7:48

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.