5

bayaraa surenjav asked to do something like

enter image description here

I came up with an answer before I realized it was closed.

John Kormylo
  • 79,712
  • 3
  • 50
  • 120

1 Answers1

3

Needless to say, this is not the only approach possible.

\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}

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120