如何增加 empheq 环境前后的间距(使用 tcolorbox)?

如何增加 empheq 环境前后的间距(使用 tcolorbox)?

我想问一个问题,如何正确增加 empheq 环境中设置的框前后的间距。这是我使用 LuaLaTeX 编译的 MWE。

\documentclass{scrbook}[DIV=15]
\usepackage{setspace}\setdisplayskipstretch{}
\usepackage{mathtools}
\usepackage{physics}
\usepackage[theorems]{tcolorbox} % Colored boxes
\usepackage{empheq} % Emphasize equations

\tcbset{highlight math style={colback=black!5!white,colframe=black,boxrule=1pt,capture=hbox,arc=0mm,boxsep=0pt}}

\begin{document}
\onehalfspacing
\KOMAoptions{DIV=current}
\chapter{Basic Properties of Numbers}
\section{Laws of Inequalities}
\subsection{Absolute Value and the Triangle Inequality}

The fact that \(-a > 0\) if \(a < 0\) is the basis of a concept which will play an extremely important role in this book. For any number \(a\), we define the \textbf{absolute value} \(\abs{a}\) of \(a\) as follows:
\begin{empheq}[box=\tcbhighmath]{equation*}
    \abs{a} =
    \begin{cases*}
        \phantom{-}a, & if \(a\geq 0\) \\
        -a, & if \(a\leq 0\). 
    \end{cases*} 
\end{empheq}
Note that \(\abs{a}\) is always positive, except when \(a = 0\). For example, we have \(\abs{-3} = 3\), \(\abs{7} = 7\), \(\abs{1 + \sqrt{2} - \sqrt{3}} = 1 + \sqrt{2} - \sqrt{3}\), and \(\abs{1 + \sqrt{2} - \sqrt{10}} = \sqrt{10} - \sqrt{2} - 1\). In general, the most straigtforward approach to any problem involving absolute values requires treating several cases separately, since absolute values are defined by cases to begin with. This approach may be used to prove the following very important fact about absolute values.
\end{document}

第一分钟

我尝试使用选项before skipafter skip提供tcolorbox包裹。

\documentclass{scrbook}[DIV=15]
\usepackage{setspace}\setdisplayskipstretch{}
\usepackage{mathtools}
\usepackage{physics}
\usepackage[theorems]{tcolorbox} % Colored boxes
\usepackage{empheq} % Emphasize equations

\tcbset{highlight math style={colback=black!5!white,colframe=black,boxrule=1pt,capture=hbox,arc=0mm,boxsep=0pt,before skip=2.5em, after skip=2.5em}}

\begin{document}
\onehalfspacing
\KOMAoptions{DIV=current}
\chapter{Basic Properties of Numbers}
\section{Laws of Inequalities}
\subsection{Absolute Value and the Triangle Inequality}

The fact that \(-a > 0\) if \(a < 0\) is the basis of a concept which will play an extremely important role in this book. For any number \(a\), we define the \textbf{absolute value} \(\abs{a}\) of \(a\) as follows:
\begin{empheq}[box=\tcbhighmath]{equation*}
    \abs{a} =
    \begin{cases*}
        \phantom{-}a, & if \(a\geq 0\) \\
        -a, & if \(a\leq 0\). 
    \end{cases*} 
\end{empheq}
Note that \(\abs{a}\) is always positive, except when \(a = 0\). For example, we have \(\abs{-3} = 3\), \(\abs{7} = 7\), \(\abs{1 + \sqrt{2} - \sqrt{3}} = 1 + \sqrt{2} - \sqrt{3}\), and \(\abs{1 + \sqrt{2} - \sqrt{10}} = \sqrt{10} - \sqrt{2} - 1\). In general, the most straigtforward approach to any problem involving absolute values requires treating several cases separately, since absolute values are defined by cases to begin with. This approach may be used to prove the following very important fact about absolute values.
\end{document}

第二轮

但它似乎在环境中不起作用empheq。有什么方法可以增加环境前后的间距吗empheq?(\vspace如果可能的话最好不使用。)谢谢。

答案1

略有变化:

\vskip .5cm % <<<--- added
 \begin{empheq}[box=\tcbhighmath]{equation*}
    \abs{a} =
    \begin{cases*}
        \phantom{-}a, & if \(a\geq 0\) \\
        -a, & if \(a\leq 0\). 
    \end{cases*} 
\end{empheq}
\vskip .5cm %<<<--- added

你会得到这样的结果:

在此处输入图片描述

相关内容