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!

2

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}
  • brilliant, thank you! also, this is a simple template for understanding how to redefine stuff – SDM Mar 10 '17 at 20:26

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.