TransWikia.com

How can I typeset cross-method factorization tables?

TeX - LaTeX Asked by Lok on June 29, 2021

I would like something akin to this:

A cross-method factorization "chart"

I have tried tabular but I couldn’t get the red lines (crosses). Thanks in advance.

3 Answers

Another solution with pstricks:

documentclass{article}

usepackage[table, svgnames]{xcolor}
usepackage{pst-node}

begin{document}

$ renewcommand{arraystretch}{1.25}begin{array}{l!{hskip0.8em}ll>{columncolor{Tan}}l }
mpnode[0.4ex, 0.5ex]{a} & pnode[-0.4ex, 0.5ex]{b}-n & -2n & -3n 
mpnode[0.45ex, 0.5ex]{c}& pnode[-0.4ex, 0.5ex]{d}-12n & -6n & -4n 
hline
& -mn-12mn & -2mn-6mn & -3mn-4mn 
&=-13mn & =-8mn & =-7mn
psset{linecolor=Coral, linewidth=0.5pt}ncline{a}{d}ncline{b}{c}
end{array} $

end{document}

enter image description here

Answered by Bernard on June 29, 2021

Here is a MWE with TikZ:

enter image description here

documentclass{article}

usepackage[table, svgnames]{xcolor}
usepackage{tikz}
usetikzlibrary{tikzmark,arrows.meta}

begin{document}

begin{tabular}{
                >{$}l<{quad $} % Controls the gap size
                @{}
                *{2}{>{$}l<{$}}
                >{columncolor{Tan}$}l<{$}
               }
tikzmarknode{A}{m} & tikzmarknode{B}{-n}      & -2n       & -3n  % TikZ nodes are defined as A, B, C and D.
tikzmarknode{C}{m} & tikzmarknode{D}{-12n}    & -6n       & -4n 
hline
                    & -mn-12mn                  & -2mn-6mn  & -3mn-4mn 
                    &=-13mn                     & =-8mn     & =-7mn
end{tabular}
begin{tikzpicture}[overlay,remember picture]
draw[Coral,-{Stealth[length=1mm]}] (A.east) -- (D.west); % Lines are drawn with arrow size. You can use ([yshift=<amount>pt,xshift=<amount>pt]A.east) to shift the positions of the lines relative to the anchor points.
draw[Coral,-{Stealth[length=1mm]}] (C.east) -- (B.west);
end{tikzpicture}
end{document}

I used @campa MWE as a template.

Answered by azetina on June 29, 2021

With nicematrix.

documentclass{article}
usepackage{xcolor}
usepackage{nicematrix}
usepackage{tikz}

begin{document}

$ renewcommand{arraystretch}{1.25}
begin{NiceArray}{l!{quad}ll>{columncolor{red!15}}l}[colortbl-like]
m & -n & -2n & -3n 
m& -12n & -6n & -4n 
hline
& -mn-12mn & -2mn-6mn & -3mn-4mn 
&=-13mn & =-8mn & =-7mn
CodeAfter tikz draw [red] (1-1.east) -- (2-2.west) 
                             (1-2.west) -- (2-1.east) ;
end{NiceArray} $

end{document}

You need several compilations (because nicematrix use PGF/Tikz nodes).

Output of the above code

Answered by F. Pantigny on June 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP