我想自动化描述的缩进过程这里-- 在这种情况下,在每个 ((sub)sub)section 之后,您必须用 \begin{adjustwidth}{left indent}{right indent} \end{adjust width} 将所有文本括起来,这似乎是多余的。一定有一种更巧妙的方法来重新定义 ((sub)sub)section 以自动合并它,但我是一个 TeX 新手。非常感谢任何建议!
答案1
\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}