I’ve got a framed environment of the memoir class with content like this:
\begin{framed}
\subsection{Article 1}
Content of Article 1
\subsection{Article 2}
Content: Article 2
\end{framed}
This renders in the following way:
._________________.
| | <-- superfluous whitespace
| Article 1 |
| Content of Art- |
| icle 1 |
| |
| Article 2 |
| Content: Artic- |
| le 2 |
.-----------------.
The \subsection{} is introducing the whitespace preceding itself, which I’d prefer not to be there inside this framed environment, though I do want such whitespace in regular text (i.e. outside the framed environment) and for subsections-after-the first one.
When inside the framed environment, I’d like to have formatting essentially like this:
._________________.
| Article 1 |
| Content of Art- |
| icle 1 |
| |
| Article 2 |
| Content: Artic- |
| le 2 |
.-----------------.
Any thoughts or suggestions as to how one may achieve this modification to headings at the beginning of the framed environment would be much appreciated.
Edit: Based on mkluwe‘s comments, I’ve rooted out the \subsection command in memoir.cls:
3314 \newcommand{\subsection}{%
3315 \subsechook%
3316 \@startsection{subsection}{2}% level 2
3317 {\subsecindent}% heading indent
3318 {\beforesubsecskip}% skip before the heading
3319 {\aftersubsecskip}% skip after the heading
3320 {\normalfont\subsecheadstyle}} % font
3321 \newcommand{\subsechook}{}
3322 \newcommand{\setsubsechook}[1]{\renewcommand{\subsechook}{#1}}
3323 \newlength{\subsecindent}
3324 \newcommand{\setsubsecindent}[1]{\setlength{\subsecindent}{#1}}
3325 \setsubsecindent{\z@}
3326 \newskip\beforesubsecskip
3327 \newcommand{\setbeforesubsecskip}[1]{\setlength{\beforesubsecskip}{#1}}
3328 \setbeforesubsecskip{-3.25ex \@plus -1ex \@minus -.2ex}
3329 \newskip\aftersubsecskip
3330 \newcommand{\setaftersubsecskip}[1]{\setlength{\aftersubsecskip}{#1}}
3331 \setaftersubsecskip{1.5ex \@plus .2ex}
So a corollary to my question above would seem to be: How can one refine this subsection command such that e.g. if it’s the first element in an environment (such as the framed environment) its \beforesubsecskip is very small?
Thank you for reading.
Sincerely,
Brian
If it happens infrequently enough you could just use a vspace command as first entry inside each frame. You could even create a new frame environment to do it automatically. In any case you would need to tweak the vspace to take away the right amount of padding. As you want, the new environment below will remove padding for first subsection entry but not for the subsequent ones:
I do understand that the problem is “with the subsection”. However I think fixing it by creating a new environment is going to be cleaner solution than trying to alter the subsection command so it intelligently avoids adding space depending on where it is.