![分部积分表示方案](https://linux22.com/image/385690/%E5%88%86%E9%83%A8%E7%A7%AF%E5%88%86%E8%A1%A8%E7%A4%BA%E6%96%B9%E6%A1%88.png)
答案1
希望这可以帮助你:
\documentclass{book}
\usepackage{amsmath}
\begin{document}
\[
\int x\mathbf{\ln} x\,dx=\begin{vmatrix}
\boldsymbol{u} = \ln x &\boldsymbol{u'}=\dfrac{1}{x}\\[12pt]
v'=x &v=\frac{x^2}{2}
\end{vmatrix}
\]
\end{document}
答案2
我建议一种更清晰的语法,该语法还允许通过仅改变定义而不是输入来实现方案的不同实现。
在第二个例子中,线条彼此太靠近,因此我添加了[1ex]
可选参数来将它们分开。
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\byparts}{O{0pt}m}
{
\keys_set:nn { elisabeth/byparts } { #2 }
\elisabeth_byparts:n { #1 }
}
\keys_define:nn { elisabeth/byparts }
{
u .tl_set:N = \l__elisabeth_byparts_u_tl,
u' .tl_set:N = \l__elisabeth_byparts_up_tl,
v .tl_set:N = \l__elisabeth_byparts_v_tl,
v' .tl_set:N = \l__elisabeth_byparts_vp_tl,
}
\cs_new_protected:Nn \elisabeth_byparts:n
{
\begin{vmatrix}\,\begin{aligned}
& u = \l__elisabeth_byparts_u_tl && u' = \l__elisabeth_byparts_up_tl
\\[#1]
& v' = \l__elisabeth_byparts_vp_tl && v = \l__elisabeth_byparts_v_tl
\end{aligned}\,\end{vmatrix}
}
\ExplSyntaxOff
\begin{document}
Without optional argument
\begin{equation*}
\int x\sin x\,dx =
\byparts{
u = x,
u' = 1,
v' = \sin x,
v = -\cos x
}
\end{equation*}
and with optional argument for opening up
\begin{equation*}
\int x\ln x\,dx =
\byparts[1ex]{
u = \ln x,
u' = \frac{1}{x},
v' = x,
v = \frac{x^2}{2}
}
\end{equation*}
\end{document}
例如,看到结果后,我选择不在等号处对齐,但通过改变 的定义是可以的\elisabeth_bypart:n
。如果我把它改成
\cs_new_protected:Nn \elisabeth_byparts:n
{
\begin{vmatrix}\,\begin{aligned}
u\hphantom{'} &= \l__elisabeth_byparts_u_tl
&
u' &= \l__elisabeth_byparts_up_tl
\\[#1]
v' &= \l__elisabeth_byparts_vp_tl
&
v\hphantom{'} &= \l__elisabeth_byparts_v_tl
\end{aligned}\,\end{vmatrix}
}
输出将变成,无需更改文档代码,