![第一个例子](https://linux22.com/image/437447/%E7%AC%AC%E4%B8%80%E4%B8%AA%E4%BE%8B%E5%AD%90.png)
答案1
欢迎来到 TeX.SE!!
我会使用(tikz) 库中的tikz
和 来执行此操作。该库也可用于控制位置(可以根据需要进行改进)。matrix of math nodes
matrix
calc
类似下面的内容:
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc,matrix}
\begin{document}
\begin{tikzpicture}[line cap=round]
\matrix(M)[blue,matrix of math nodes,
row 3/.style={black},
row 4/.style={black},
]
{%
1 & & & & \\
2 & & 1 & & \\
4 & \times & 5 & \times & 3 \\
{} & 2 & \times & 10 & {}\\
& 1 & & 2 & \\
& & & 1 & \\
};
\draw (M-3-1.south west) -- (M-3-5.south east);
\foreach\i/\j in {2/1,3/1,3/3,4/2,4/4,5/4}
\draw[blue] ($(M-\i-\j.north west)-(0,0.1)$) -- ($(M-\i-\j.south east)+(0,0.1)$);
\node at ($(M-3-5)!0.5!(M-4-5)+( 0.2,0.07)$) [right] {$\mathstrut=-3$};
\node at ($(M-3-1)!0.5!(M-4-1)+(-0.2,0.07)$) [left] {$\mathstrut-$};
\end{tikzpicture}
\end{document}
编辑:按照 OP 的建议,添加了减号。
答案2
第一个例子
\documentclass[preview,border=12pt]{standalone}% please change it to your own class, for example article, book, etc
\usepackage{amsmath}
\usepackage{cancel}
\begin{document}
$
\begin{aligned}
t &=\frac{\bcancel{a}\times b}{\bcancel{a}} \\
&= b
\end{aligned}
$
\end{document}
第二示例
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{cancel}
\begin{document}
Given $f(x)$. Find its derivative with respect to $x$.
\begin{align*}
f'(x) &= \frac{\cancel{\mathrm{d}}f(x)}{\cancel{\mathrm{d}} x} \\
&= \frac{f(x)}{x}
\end{align*}
\end{document}