TeX - LaTeX Asked by Weilory on March 18, 2021
Is there a way to make a version of the diagram provided above?
Thank you very much.
I'm adapting my answer to "How to add arrow in equations and matrix?"; see there for some explanations on how to draw arrows between text elements.
tikznode
command. This assigns a name to the text element and stores its size and position.tikzpicture
environment with the options remember picture,overlay
below. It contains the graphical elements, in this case the arrows. Here you will use the names assigned in the previous step.documentclass{article}
usepackage{tikz}
usetikzlibrary{arrows}% only needed for the arrow tip stealth'
newcommandtikznode[3][]{%
tikz[remember picture,baseline=(#2.base)]
node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}
begin{document}
begin{tabular}{r@{qquad}r}
tikznode{-x}{$-x$} & tikznode{1}{$1$} [2ex]
tikznode{2x}{$2x$} & tikznode{3}{$3$}
cline{2-2}
& $-x$
end{tabular}
begin{tikzpicture}[remember picture,overlay,> = stealth',shorten <= 4pt,shorten > = 4pt]
draw[->] (-x.east) -- (3.west);
draw[->] (2x.east) -- (1.west);
end{tikzpicture}
end{document}
Correct answer by gernot on March 18, 2021
Here is a solution with {NiceArray}
of nicematrix
.
That environment is similar to the classical environment {array}
(of array
) but creates PGF nodes under the cells of the array. Then, it's possible to use Tikz to draw the required arrows.
documentclass{article}
usepackage{nicematrix}
usepackage{tikz}
begin{document}
$begin{NiceArray}{r@{qquad}r}
-x & 1 [2ex]
2x & 3
cline{2-2}
& -x
CodeAfter
begin{tikzpicture}[shorten <= 4pt,shorten > = 4pt]
draw[->] (1-1.east) -- (2-2.west);
draw[->] (2-1.east) -- (1-2.west);
end{tikzpicture}
end{NiceArray}$
end{document}
You need several compilations (because nicematrix
uses PGF/Tikz nodes).
Answered by F. Pantigny on March 18, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP