阴影框的垂直空间

阴影框的垂直空间

我使用包framed来为部分文本的背景着色。我注意到shaded环境在彩色框前后使用了额外的空间。在寻找如何减少这个空间时,我找到了宏

\setlength{\OuterFrameSep}{0pt}

并尝试了一下。但我感觉这个宏不起作用。有没有办法设置\OuterFrameSep并减少垂直空间?下面我添加了示例代码

\scrollmode
\newtheorem{theorem}{Theorem}[section]
\newtheorem{definition}[theorem]{Definition}
\usepackage{xcolor}
\usepackage{framed}
\setlength{\OuterFrameSep}{0pt}
\begin{document}
\title{Test File}

\begin{abstract}
In this paper I test vertical space in shaded environment.
\end{abstract}
\maketitle

\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%

\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%

\definecolor{shadecolor}{rgb}{.94,.94,.95}%
\begin{shaded}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{shaded}%

\begin{shaded}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{shaded}%

You can see that space between definitions 3 and 4 is larger
than space between definition 1 and 2.

\end{document}
    ```

答案1

我查看了 framed.sty 文件并尝试重现它们的步骤。在下面的代码中,你会发现环境 Shaped 占用的空间比环境shaped 要小

\documentclass{amsart}
\scrollmode
\newtheorem{theorem}{Theorem}[section]
\newtheorem{definition}[theorem]{Definition}
\usepackage{xcolor}
\usepackage{framed}
\setlength{\OuterFrameSep}{0pt}
\begin{document}
\title{Test File}

\begin{abstract}
In this paper I test vertical space in shaded environment.
\end{abstract}
\maketitle
\newlength\OuterFrameSep \OuterFrameSep=0pt \relax

\newenvironment{Shaded}{%
\def\FrameCommand{\fboxsep0pt \colorbox{shadecolor}}%
  \MakeFramed {\FrameRestore}}%
 {\endMakeFramed}

\noindent
\begin{tabular}{@{}l|r}
\begin{minipage}{175pt}
\setlength{\parindent}{4mm}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%

\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{minipage}
&
\begin{minipage}{175pt}
\setlength{\parindent}{4mm}

\definecolor{shadecolor}{rgb}{.94,.94,.95}%
\begin{shaded}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{shaded}%

\begin{shaded}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{shaded}%
\end{minipage}
\end{tabular}


\noindent
\begin{tabular}{@{}l|r}
\begin{minipage}{175pt}
\definecolor{shadecolor}{rgb}{.94,.94,.95}%
\begin{shaded}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{shaded}%

\begin{shaded}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{shaded}%
\end{minipage}
&
\begin{minipage}{175pt}
\setlength{\parindent}{4mm}

\definecolor{shadecolor}{rgb}{.94,.94,.95}%
\begin{Shaded}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{Shaded}%

\begin{Shaded}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{Shaded}%
\end{minipage}
\end{tabular}


\noindent
\begin{tabular}{@{}l|r}
\begin{minipage}{175pt}
\setlength{\parindent}{4mm}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%

\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{minipage}
&
\begin{minipage}{175pt}
\setlength{\parindent}{4mm}

\definecolor{shadecolor}{rgb}{.94,.94,.95}%
\begin{Shaded}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{Shaded}%

\begin{Shaded}
\begin{definition}
Let $V$ be vector space.
The righ-side representation
$f$ of group $G$ in left vector space $V$ of columns is called
linear $G$-representation.
\qed%
\end{definition}%
\end{Shaded}%
\end{minipage}
\end{tabular}

\end{document}

它会在垂直和水平方向上减少文本周围的空间。我不确定是否可以仅在垂直方向上减少。如果我设置\fboxsep-8pt部分文本不会被颜色覆盖

相关内容