标题\ LaTeX中框架环境开头的小节,无前导填充

标题\ LaTeX中框架环境开头的小节,无前导填充,latex,whitespace,tex,Latex,Whitespace,Tex,我在回忆录课程中设置了一个框架环境,内容如下: \begin{framed} \subsection{Article 1} Content of Article 1 \subsection{Article 2} Content: Article 2 \end{framed} ._________________. | Article 1 | | Content of Art- | | icle 1 | | | | Article 2

我在
回忆录
课程中设置了一个
框架
环境,内容如下:

\begin{framed}
\subsection{Article 1}
Content of Article 1
\subsection{Article 2}
Content: Article 2
\end{framed}
._________________.
| Article 1       |
| Content of Art- |
| icle 1          |
|                 |
| Article 2       |
| Content: Artic- |
| le 2            |
.-----------------.
这将以以下方式呈现:

._________________.
|                 |   <-- superfluous whitespace
| Article 1       |
| Content of Art- |
| icle 1          |
|                 |
| Article 2       |
| Content: Artic- |
| le 2            |
.-----------------.
对于如何在
框架
环境开始时实现标题修改的任何想法或建议,我们将不胜感激


Edit:根据
mkluwe
的评论,我在
memori.cls
中删除了\subsection命令:

 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}
因此,我上述问题的一个推论似乎是:如何改进此
小节
命令,例如,如果它是环境中的第一个元素(例如
框架
环境),那么它的
\beforeCSkip
非常小


谢谢你的阅读

真诚地


Brian

我不知道这个环境,但在文档中我发现:

\框架高度调整:宏;框架顶部基线上方的框架高度 页面


您可能会尝试欺骗…

作为一个快速而肮脏的解决方案,我从
文章中复制了
\subsection
命令的定义。cls
并删除了垂直跳过:

\documentclass{article}
\usepackage{framed}
\makeatletter
\newcommand\subsectionx{\@startsection{subsection}{2}{\z@}%
                                     {0ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\large\bfseries}}
\makeatother
\begin{document}
\begin{framed}
\subsectionx{Article 1}
Content of Article 1
\subsection{Article 2}
Content: Article 2
\end{framed}
\end{document}

如果这种情况很少发生,您可以使用vspace命令作为每个帧内的第一个条目。您甚至可以创建一个新的框架环境来自动执行此操作。在任何情况下,您都需要调整vspace以去除适当的填充量。如您所愿,下面的新环境将删除第一个子部分条目的填充,但不会删除后续条目的填充:

\newenvironment{subsectframe}{\begin{framed}\vspace{-1.0\baselineskip}}{\end{framed}}

\begin{document}

\begin{subsectframe}
\subsection{Article 1}
Content of Article 1
\subsection{Article 2}
Content: Article 2
\end{subsectframe}

\end{document}

我明白问题在于“该款”。但是,我认为通过创建一个新环境来修复它将是一个比试图改变subsection命令更干净的解决方案,这样它可以智能地避免根据位置添加空间。

感谢您的回复;我尝试过修补
\FrameHeightAdjust
,但似乎没有任何效果。我想问题出在
\subsection
命令中,就像我的编辑一样。谢谢你的回答。这一小节肯定是行动所在。但是,我不想删除所有子部分的垂直跳过——只删除启动新环境的子部分。是的,您是否尝试运行我的示例?我提供了一个新命令\subsectionx,它消除了垂直跳过。这用于启动框架环境中的第一个子部分。我想你忽略了附加的“x”(我应该让它更明显)。谢谢。这正是我想要的。我不知道
\vspace
可能有负面属性!我可以解决的一个警告是,当
框架
环境以
\subsection
以外的内容开始时(或具有前导空格的等效内容),文本从框架行的顶部开始,即
\vspace{-1.0\baselineskip}
占用了太多的空间。理想情况下,
\vspace
仅在帧以
\subsection
或等效项开头时出现。@Brian:是的,新环境假定您对其中的内容有一定的了解。因此,如果它是一个以小节开始的框架,你使用新的“子框架”,如果它没有初始小节,那么就使用一个常规的“框架”环境。如果您经常编辑内容,并且内容在一个帧内经常发生更改(即,从具有初始子节更改为不具有),那么最好不要使用新的帧环境,只需根据需要使用vspace命令即可。