I have a document where there are some sections with and some without subsections. When there are subsections, I want them (and all their content) to be indented. I have found several approaches to this which basically come down to the following two:
Using a minipage
This comes with two problems: Sections can't be broken over pages and floats can't float into or out of the minipage, so all floats would have to be placed between sections in the source as well as in the output.
Using addmargin (or adjustwidth)
(The addmargin environment is provided by KOMA-script and the adjustwidth environment by the changepage package.)
This one doesn't have the problems a minipage has, but sectioning commands don't seem to work inside these environments at all. I get the error
Something's wrong--perhaps a missing \item..
How can I achieve the indentation without having any of these problems?
MWE:
\documentclass[parskip=half]{scrartcl}
\begin{document}
\section{Using minipage}
\hfill\begin{minipage}{\dimexpr\textwidth-2cm}
\subsection{A Subsection}
First table declared here.
\begin{table}
\centering
\caption{some table}
\begin{tabular}{c c}
1, 1 & 1, 2 \\
2, 1 & 2, 2 \\
\end{tabular}
\end{table}
\subsection{Another Subsection}
Plain text.
\end{minipage}
\section{Using addmargin}
\begin{addmargin}[2cm]{0cm}
\subsection{A Subsection}
Second table declared here
\begin{table}
\centering
\caption{some table}
\begin{tabular}{c c}
1, 1 & 1, 2 \\
2, 1 & 2, 2 \\
\end{tabular}
\end{table}
\subsection{Another Subsection}
Plain text.
\end{addmargin}
\end{document}
Output:
