在数学题中添加划线

在数学题中添加划线

巴亚拉·苏伦扎夫 做类似的事情

在此处输入图片描述

在我意识到它被关闭之前,我想到了一个答案。

答案1

不用说,这不是唯一可能的方法。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}% not used yet

\newcommand{\tikzgroup}[2]% #1 = math, #2 = node name
  {\tikz[baseline=(#2.base), remember picture] {\node[inner sep=0pt] (#2) {$#1$};}}

\begin{document}
\hrule% size test
\begin{equation*}
\rule[-2\baselineskip]{0pt}{5\baselineskip}% reserve space
\frac{\tikzgroup{4}{N1} \times \tikzgroup{5}{N2} \times \tikzgroup{3}{N3}}%
  {\tikzgroup{2}{D1} \times \tikzgroup{10}{D2}}
\end{equation*}
\hrule% size test
\begin{tikzpicture}[overlay, remember picture]
  \draw[blue] (N1.north west) -- (N1.south east)% cross out
              (N2.north west) -- (N2.south east)
              (N3.north west) -- (N3.south east)
              (D1.north west) -- (D1.south east)
              (D2.north west) -- (D2.south east);
  \node[above={\dp\strutbox}, blue, inner sep=0pt] (NN1) at(N1.north) {2};
  \node[above={\dp\strutbox}, blue, inner sep=0pt] at (N2.north) {1};
  \node[below={\dp\strutbox}, blue, inner sep=0pt] at (D1.south) {1};
  \node[below={\dp\strutbox}, blue, inner sep=0pt] at (D2.south) (DD2) {2};
  \node[above={\dp\strutbox}, blue, inner sep=0pt] at(NN1.north) {1};
  \node[below={\dp\strutbox}, blue, inner sep=0pt] at (DD2.south) {1};
  \draw[blue] (NN1.north west) -- (NN1.south east)
              (DD2.north west) -- (DD2.south east);
\end{tikzpicture}
\end{document}

演示

相关内容