1

I'd like to automate the indentation process described here -- in that case, after every single ((sub)sub)section you must bracket all text with \begin{adjustwidth}{left indent}{right indent} \end{adjust width}, which seems redundant. There must be a slicker way to redefine ((sub)sub)section to automatically incorporate this, but I'm a relative TeX novice. Any advice very much appreciated!

0

1 Answer 1

3

enter image description here

\documentclass{article}
\usepackage{changepage,lipsum,titlesec}% http://ctan.org/pkg/{changepage,lipsum,titlesec}
\titleformat{\section}[block]{\bfseries}{\thesection.}{1em}{}
\titleformat{\subsection}[block]{}{\thesubsection}{1em}{}
\titleformat{\subsubsection}[block]{}{\thesubsubsection}{1em}{}
\titlespacing*{\subsection} {\leftmargin}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection} {\leftmargin}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeatletter
\let\xsection\section
\def\section{\par
  \leftmargin0\p@
  \leftskip\leftmargin
  \@totalleftmargin\leftmargin\linewidth\textwidth
  \xsection}
\let\xsubsection\subsection
\def\subsection{\par
  \leftmargin20\p@
  \leftskip\leftmargin
  \@totalleftmargin\leftmargin\linewidth\dimexpr\textwidth-\leftmargin\relax
  \xsubsection}
\let\xsubsubsection\subsubsection
\def\subsubsection{\par
  \leftmargin40\p@
  \leftskip\leftmargin
  \@totalleftmargin\leftmargin\linewidth\dimexpr\textwidth-\leftmargin\relax
  \xsubsubsection}

\begin{document}
\section{A section}
\lipsum[1]
\subsection{A subsection}
  \lipsum[2]
\subsubsection{A subsubsection}
  \lipsum[3]
\section{A section}
\lipsum[1]
\subsection{A subsection}
  \lipsum[2]
\subsubsection{A subsubsection}
  \lipsum[3]

\end{document}
1
  • brilliant, thank you! also, this is a simple template for understanding how to redefine stuff
    – SDM
    Mar 10, 2017 at 20:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .