我不想使用为其\allowdisplaybreak
设计的显示数学环境。简而言之,是否可以alined
通过定义类似的东西来打破以下内容\allowinlinebreak
?
\documentclass{article}
\usepackage[a6paper,vmargin=15mm,hmargin=5mm]{geometry}
\usepackage{times}
\usepackage{helvet}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\allowdisplaybreaks
\usepackage{tcolorbox}
\usepackage{microtype}
\tcbuselibrary{breakable}
\newcounter{exercise}[subsection]
\@addtoreset{exercise}{section}
\renewcommand{\theexercise}{%
\ifnum\value{subsection}>0\relax
\thesubsection
\else
\thesection
\fi
.\arabic{exercise}%
}
\newenvironment{exercise}
{\par\smallskip\refstepcounter{exercise}
\begin{tcolorbox}[breakable,title=Exercise \theexercise,left=0mm,lefttitle=2mm]\ignorespaces}
{\end{tcolorbox}\par\smallskip\ignorespacesafterend}
\newif\ifinitialized
\initializedfalse
\newlength\EWD
\newlength\HWD
\def\Initializer{%
\ifinitialized
\else
\initializedtrue
\settowidth{\EWD}{${}={}$}%
\setlength{\HWD}{0.5\dimexpr\linewidth-\EWD\relax}%
\fi}
\AtBeginDocument{%
\expandafter\def\expandafter\item\expandafter{%
\expandafter\Initializer\item}%
}
\newenvironment{multi}
{\multlined[t][\HWD]}
{\endmultlined}
\begin{document}
\begin{exercise}
Simplify the following
\begin{enumerate}
\item $\frac{3x-2}{2(x-1)}-\frac{3(x+1)}{x+2}$
\end{enumerate}
\tcblower
\begin{enumerate}
\item
$\!
\begin{aligned}[t]
\frac{3x-2}{2(x-1)}-\frac{3(x+1)}{x+2}
&= \begin{multi}
\frac{3x-2}{2(x-1)}\times\frac{x+2}{x+2}\\
{}-\frac{3(x+1)}{x+2}\times\frac{2(x-1)}{2(x-1)}
\end{multi}\\
&= \begin{multi}
\frac{(3x-2)(x+2)}{2(x-1)(x+2)}\\
{}-\frac{6(x+1)(x-1)}{2(x+2)(x-1)}
\end{multi}\\
&= \begin{multi}
\frac{3x^2 +6x -2x -4}{2(x-1)(x+2)}\\
{}-\frac{6(x^2 -x +x -1)}{2(x+2)(x-1)}
\end{multi}\\
&= \begin{multi}
\frac{3x^2 +4x -4}{2(x-1)(x+2)}\\
{}-\frac{6(x^2 -1)}{2(x+2)(x-1)}
\end{multi}\\
&= \begin{multi}
\frac{3x^2 +4x -4}{2(x-1)(x+2)}\\
{}-\frac{6x^2 -6}{2(x+2)(x-1)}
\end{multi}\\
&= \begin{multi}
\frac{3x^2 +4x -4}{2(x-1)(x+2)}\\
{}+\frac{-(6x^2 -6)}{2(x+2)(x-1)}
\end{multi}\\
&= \frac{3x^2 +4x -4 -(6x^2 -6)}{2(x-1)(x+2)}\\
&= \frac{3x^2 +4x -4 -6x^2 +6}{2(x-1)(x+2)}\\
&= \frac{-3x^2 +4x +2}{2(x-1)(x+2)}
\end{aligned}
$
\end{enumerate}
\end{exercise}
\end{document}
答案1
使用内联数学所以这样做是错误的(但每次你发例子时我都会说同样的话)。但是如果你必须这样做,那么你必须……
\documentclass{article}
\usepackage[a6paper,vmargin=15mm,hmargin=5mm]{geometry}
\usepackage{times}
\usepackage{helvet}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\allowdisplaybreaks
\usepackage{tcolorbox}
\usepackage{microtype}
\tcbuselibrary{breakable}
\newcounter{exercise}[subsection]
\@addtoreset{exercise}{section}
\renewcommand{\theexercise}{%
\ifnum\value{subsection}>0\relax
\thesubsection
\else
\thesection
\fi
.\arabic{exercise}%
}
\newenvironment{exercise}
{\par\smallskip\refstepcounter{exercise}
\begin{tcolorbox}[breakable,title=Exercise \theexercise,left=0mm,lefttitle=2mm]\ignorespaces}
{\end{tcolorbox}\par\smallskip\ignorespacesafterend}
\newif\ifinitialized
\initializedfalse
\newlength\EWD
\newlength\HWD
\def\Initializer{%
\ifinitialized
\else
\initializedtrue
\settowidth{\EWD}{${}={}$}%
\setlength{\HWD}{0.5\dimexpr\linewidth-\EWD\relax}%
\fi}
\AtBeginDocument{%
\expandafter\def\expandafter\item\expandafter{%
\expandafter\Initializer\item}%
}
\newenvironment{multi}
{\multlined[t][\HWD]}
{\endmultlined}
\begin{document}
\begin{exercise}
Simplify the following
\begin{enumerate}
\item $\frac{3x-2}{2(x-1)}-\frac{3(x+1)}{x+2}$
\end{enumerate}
\tcblower
\begin{enumerate}
\item
\setbox0\vbox{\rightskip\fill$\break\begin{aligned}[t]
\frac{3x-2}{2(x-1)}-\frac{3(x+1)}{x+2}
&= \begin{multi}
\frac{3x-2}{2(x-1)}\times\frac{x+2}{x+2}\\
{}-\frac{3(x+1)}{x+2}\times\frac{2(x-1)}{2(x-1)}
\end{multi}\\
&= \begin{multi}
\frac{(3x-2)(x+2)}{2(x-1)(x+2)}\\
{}-\frac{6(x+1)(x-1)}{2(x+2)(x-1)}
\end{multi}\\
&= \begin{multi}
\frac{3x^2 +6x -2x -4}{2(x-1)(x+2)}\\
{}-\frac{6(x^2 -x +x -1)}{2(x+2)(x-1)}
\end{multi}\\
&= \begin{multi}
\frac{3x^2 +4x -4}{2(x-1)(x+2)}\\
{}-\frac{6(x^2 -1)}{2(x+2)(x-1)}
\end{multi}\\
&= \begin{multi}
\frac{3x^2 +4x -4}{2(x-1)(x+2)}\\
{}-\frac{6x^2 -6}{2(x+2)(x-1)}
\end{multi}\\
&= \begin{multi}
\frac{3x^2 +4x -4}{2(x-1)(x+2)}\\
{}+\frac{-(6x^2 -6)}{2(x+2)(x-1)}
\end{multi}\\
&= \frac{3x^2 +4x -4 -(6x^2 -6)}{2(x-1)(x+2)}\\
&= \frac{3x^2 +4x -4 -6x^2 +6}{2(x-1)(x+2)}\\
&= \frac{-3x^2 +4x +2}{2(x-1)(x+2)}
\end{aligned}\break$\par
\unskip\setbox0\lastbox\unskip\unpenalty
\setbox0\lastbox
\setbox0\hbox{\unhbox0\unskip\unpenalty\global\setbox1\lastbox}}%
\unvbox1
\end{enumerate}
\end{exercise}
\end{document}