我所做的就是用 LaTeX 编写一个分部积分表。我似乎在任何地方都找不到 .tex 代码示例,尽管我见过 PDF 格式的此类表格的图片(例如http://cazelais.disted.camosun.bc.ca/187/parts.pdf例如)。希望有人能尽快告诉我。
答案1
我假设您问的是分部积分的表格方法,一种方法是用来tikzmark
记录点的位置,然后在表格后在相应点之间画出箭头:
笔记:
这确实需要两次运行。第一次确定位置,第二次进行绘图。
来自
\tikzmark
在正文旁边添加大括号。您可以通过 全局改变箭头的样式
Arrow Style
。
代码
\documentclass{article}
\usepackage{booktabs}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{Arrow Style/.style={text=black, font=\boldmath}}
\newcommand{\tikzmark}[1]{%
\tikz[overlay, remember picture, baseline] \node (#1) {};%
}
\newcommand*{\XShift}{0.5em}
\newcommand*{\YShift}{0.5ex}
\NewDocumentCommand{\DrawArrow}{s O{} m m m}{%
\begin{tikzpicture}[overlay,remember picture]
\draw[->, thick, Arrow Style, #2]
($(#3.west)+(\XShift,\YShift)$) --
($(#4.east)+(-\XShift,\YShift)$)
node [midway,above] {#5};
\end{tikzpicture}%
}
\begin{document}
\[
\renewcommand{\arraystretch}{1.5}
\begin{array}{c @{\hspace*{1.0cm}} c}\toprule
D & I \\\cmidrule{1-2}
x^2\tikzmark{Left 1} & \tikzmark{Right 1}e^2x \\
2x \tikzmark{Left 2} & \tikzmark{Right 2}\frac{1}{2} e^{2x} \\
2 \tikzmark{Left 3} & \tikzmark{Right 3}\frac{1}{4} e^{2x} \\
0 \tikzmark{Left 4} & \tikzmark{Right 4}\frac{1}{8} e^{2x} \\\bottomrule
\end{array}
\]
%-----------------------------------------
\DrawArrow[draw=red]{Left 1}{Right 2}{$+$}%
\DrawArrow[draw=brown]{Left 2}{Right 3}{$-$}%
\DrawArrow[draw=blue]{Left 3}{Right 4}{$+$}%
\end{document}
答案2
首先:箭头有多种方法。我会让其他人解释tikz
解决方案。但您可以使用pstricks
和pst-nodes
来实现它。
梅威瑟:
\documentclass{article}
\usepackage{amsmath}
\usepackage{pstricks,pst-node}
\pagestyle{empty}
\newcommand{\diff}[1]{\mathrm{d}#1}
\newcommand{\me}{\mathrm{e}}
\begin{document}
\noindent Use \verb=\boxed{...}= to enclose the contents of an equation in a frame.
\[
\boxed{\int_0^\infty \me^{-x^2}\diff{x}}
\]
Use \verb=\quad= and \verb=\text{...}= to add space and add regular
text in an equation
\[
u = x \quad \text{ and } \quad \diff v = \cos x \diff x
\]
Use the \verb=align= environment to align math equation upon a given
position in the equation indicated by \verb=&=
\begin{align*}
\int x \cos x \diff{x} &= x \sin x - \int \sin x \diff x \\
&= x \sin x + \cos x +C
\end{align*}
\noindent\verb=pstricks= provides \verb=pst-node= to allow you to label and
connect nodes.
\renewcommand{\arraystretch}{3}
\[\begin{array}{c@{\hspace*{6em}}c}
D & I \\\hline
x^2\rnode[br]{A1}{} & \me^{2ex} \\
2x\rnode[br]{B1}{} & \rnode[l]{B2}{}\frac{1}{2}\me^{2x} \\
2\rnode[br]{C1}{} & \rnode[l]{C2}{}\frac{1}{4}\me^{2x}
\end{array}\]
%%
\ncline[nodesep=1em,arrows=->]{A1}{B2}
\lput{:U}{\rput[c]{U}(0,2ex){line label}}
%%
\ncline[nodesep=1em,arrows=->]{B1}{C2}
\lput{:U}{\rput[c]{U}(0,2ex){line label}}
\end{document}
如果您想pdflatex
使用此路线,pstricks
请尝试以下 MWE:
\documentclass{article}
\usepackage{amsmath}
\usepackage{pstricks}
\usepackage{auto-pst-pdf}
\usepackage{pst-node}
\pagestyle{empty}
\newcommand{\diff}[1]{\mathrm{d}#1}
\newcommand{\me}{\mathrm{e}}
\begin{document}
\noindent Use \verb=\boxed{...}= to enclose the contents of an equation in a frame.
\[
\boxed{\int_0^\infty \me^{-x^2}\diff{x}}
\]
Use \verb=\quad= and \verb=\text{...}= to add space and add regular
text in an equation
\[
u = x \quad \text{ and } \quad \diff v = \cos x \diff x
\]
Use the \verb=align= environment to align math equation upon a given
position in the equation indicated by \verb=&=
\begin{align*}
\int x \cos x \diff{x} &= x \sin x - \int \sin x \diff x \\
&= x \sin x + \cos x +C
\end{align*}
\noindent%
\begin{postscript}
\verb=pstricks= provides \verb=pst-node= to allow you to label and
connect nodes.
\renewcommand{\arraystretch}{3}
\[\begin{array}{c@{\hspace*{6em}}c}
D & I \\\hline
x^2\rnode[br]{A1}{} & \me^{2ex} \\
2x\rnode[br]{B1}{} & \rnode[l]{B2}{}\frac{1}{2}\me^{2x} \\
2\rnode[br]{C1}{} & \rnode[l]{C2}{}\frac{1}{4}\me^{2x}
\end{array}\]
%%
\ncline[nodesep=1em,arrows=->]{A1}{B2}
\lput{:U}{\rput[c]{U}(0,2ex){line label}}
%%
\ncline[nodesep=1em,arrows=->]{B1}{C2}
\lput{:U}{\rput[c]{U}(0,2ex){line label}}
\end{postscript}
\end{document}
这是按照以下答案中的说明进行的如何在 pdfLaTeX 中使用 PSTricks?。此外,使用环境的\begin{postscript}...\end{postscript}
说明请参考pstricks 网站
答案3
与。{NiceArray}
nicematrix
\documentclass{article}
\usepackage{nicematrix}
\usepackage{booktabs}
\usepackage{tikz}
\begin{document}
\[
\renewcommand{\arraystretch}{1.5}
\begin{NiceArray}{c @{\hspace*{1.0cm}} c}[create-medium-nodes]
\toprule
D & I \\
\cmidrule{1-2}
x^2 & e^2x \\
2x & \frac{1}{2} e^{2x} \\
2 & \frac{1}{4} e^{2x} \\
0 & \frac{1}{8} e^{2x} \\
\bottomrule
\CodeAfter
\begin{tikzpicture} [->, name suffix = -medium]
\draw [red] (2-1) -- node [above] {$+$} (3-2) ;
\draw [brown] (3-1) -- node [above] {$-$} (4-2) ;
\draw [blue] (4-1) -- node [above] {$+$} (5-2) ;
\end{tikzpicture}
\end{NiceArray}
\]
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。