I want to have a hanging indent on every paragraph, but not on the section headers. I can achieve this with titlesec
and \leftskip
, but this solution feels dirty/hackish, and I'm sure there must be a better way.
MWE:
\documentclass[12pt]{article}
\usepackage{parskip}
\usepackage{titlesec}
\titleformat{\section}[runin]{\bfseries\normalsize}{}{0pt}{\hspace*{-2em}\thesection }[\\]
\titleformat{\subsection}[runin]{\normalsize}{}{0pt}{}[:\\]
\leftskip=2em
\begin{document}
\section{Section Headings Not Indented}
Every line of this section should be indented the exact same amount. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean adipiscing lacus ut nibh laoreet malesuada. Nulla vehicula mauris eu imperdiet varius. Etiam pellentesque eros a urna pulvinar, nec condimentum lectus gravida. Suspendisse vehicula, mauris id fermentum iaculis, massa neque convallis neque, in vestibulum quam felis in enim.
Sed dapibus, nisl vitae consectetur sodales, augue sem laoreet urna, ut eleifend velit augue vel leo. Nulla facilisi. Suspendisse potenti. Phasellus scelerisque porta risus ut luctus. Ut lobortis magna purus, at rhoncus quam interdum quis. Sed vestibulum, leo non rhoncus sollicitudin, erat enim dignissim dolor, quis commodo nunc elit at arcu.
\subsection{also indented same as a paragraph}
Phasellus vitae ultricies augue. Vivamus non ipsum odio. Etiam id lectus non sapien hendrerit consectetur. Suspendisse porta magna at metus dignissim pharetra. Nulla bibendum mauris sit amet feugiat interdum. Nulla porta sollicitudin lorem eget pharetra. Etiam dictum, dolor vitae vulputate ultricies, quam nibh consectetur leo, nec ultricies felis tortor eget leo. In pulvinar felis nec diam fringilla rhoncus a at lacus.
\end{document}
I came across the hanging
package and the hangparas
environment, but that does not seem to work across multiple sections. I also considered simply adding a \hangindent
and \hangafter=0
to every paragraph, but that would be tedious and I would prefer a more global solution.
If possible, I would also like to be able to undo these settings for a given section(s) (My appendices, specifically. Currently, I do this by preceding them with \leftskip=0
). However, if that is impossible (or requires substantial additional effort), it's not a deal-breaker.
\leftskip
is not compatible with list environments; you want to have a negative indentation of the section titles, rather than a positive indentation of the text.