I want to write the expression shown in the image.
Can anybody help me on that. 
Asked
Active
Viewed 203 times
0
-
2Maybe this could help. – manooooh Aug 14 '18 at 09:53
-
1And Welcome to TeX.SE!! – manooooh Aug 14 '18 at 09:54
-
1Possible duplicate of Array of numbers with arrows – Aug 15 '18 at 00:23
2 Answers
6
Here is the MWE
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.markings,arrows}
\tikzset{->-/.style={decoration={
markings,
mark=at position #1 with {\arrow{>}}},postaction={decorate}}}
\setbeamertemplate{navigation symbols}{}
\begin{document}
\begin{frame}[fragile]
\centering
\begin{tikzpicture}[>=latex]
\matrix (m) [matrix of nodes, row sep=3em, column sep=3em]
{
(1,1) & (1,2) & (1,3) & \ldots \\
(2,1) & (2,2) & (2,3) & \ldots \\
(3,1) & (3,2) & (3,3) & \ldots \\
\vdots \\
};
\draw[->-=.6] (m-1-1.north east) -- (m-1-1.south west) node[midway,sloped,above=.5cm] {1};
\draw[->-=.5] (m-1-2.north east) -- (m-2-1.south west) node[near end,xshift=-.2cm,sloped,above=.3cm] {3};
\path (m-1-2.north east) -- (m-2-1.south west) node[near end,xshift=3cm,sloped,above=.3cm] {2};
\draw[->-=.3] (m-1-3.north east) -- (m-3-1.south west) node[midway,above=.2cm,xshift=.5cm,sloped] {5} node[near end,xshift=-.6cm,above=.3cm,sloped] {6};
\path (m-1-3.north east) -- (m-3-1.south west) node[near end,xshift=5.1cm,above=.3cm,sloped] {4};
\end{tikzpicture}
\end{frame}
\end{document}
current_user
- 5,235
-
1
-
-
1Did you compile two times? It works just fine for me. Which error do you get? – samcarter_is_at_topanswers.xyz Aug 15 '18 at 09:23
-
@samcarter: Yes, I did. Here are the errors: : File ended while scanning use of \next. : No file texstudio_Ot3059.nav. – current_user Aug 15 '18 at 09:51
-
1OK, then can you please show the error message you get? – samcarter_is_at_topanswers.xyz Aug 15 '18 at 09:53
-
1The first pair of integers at the top left is (1,1) and not (1,4). The arrow is superimposed on the 1 and gives the impression of a 4. – AndréC Aug 15 '18 at 13:32
4
a slightly modified current-user answer with attempt to make code more concise and clear:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.markings,arrows}
\setbeamertemplate{navigation symbols}{}
\begin{document}
\begin{frame}[fragile]
\begin{tikzpicture}[
->-/.style = {decoration={markings,
mark=at position #1 with {\arrow{latex}}},postaction={decorate},
very thick, shorten >=-1mm, shorten <=-1mm},
base/.style = {font=\scriptsize, sloped, above},
rlbl/.style = {base, at start}, % for nodes on the right end of arrows
llbl/.style = {base, at end}, % for nodes on the left end of arrows
]
\matrix (m) [matrix of nodes, row sep=1em, column sep=1em]
{
(1,4) & (1,2) & (1,3) & \ldots \\
(2,1) & (2,2) & (2,3) & \ldots \\
(3,1) & (3,2) & (3,3) & \ldots \\
\vdots & & & \\
};
\begin{scope}[transparency group, fill opacity=0.5,]
\draw[->-=.6] (m-1-1.north east) -- (m-1-1.south west) node[rlbl] {1};
\draw[->-=.5] (m-1-2.north east) -- (m-2-1.south west) node[llbl] {3} node[rlbl] {2};
\draw[->-=.3] (m-1-3.north east) -- (m-3-1.south west) node[llbl] {5} node[rlbl] {4};
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}
edit (2): considering comment of Teepeemm and Marian G. for improved paralelism of sloped lines:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.markings,arrows}
\setbeamertemplate{navigation symbols}{}
\begin{document}
\begin{frame}[fragile]
\[
\begin{tikzpicture}[
->-/.style = {decoration={markings,
mark=at position #1 with {\arrow{latex}}},postaction={decorate},
very thick},
base/.style = {font=\scriptsize, sloped, above=0.1ex},
rlbl/.style = {base, xshift=-1.0em, at start}, % for nodes on the right end of arrows
llbl/.style = {base, xshift= 1.5em, at end}, % for nodes on the left end of arrows
]
\matrix (m) [matrix of math nodes,
nodes={minimum width=2em, inner sep=0pt, outer sep=0pt},
row sep=1.64ex, column sep=1.64em]
{
(1,1) & (1,2) & (1,3) & \ldots \\
(2,1) & (2,2) & (2,3) & \ldots \\
(3,1) & (3,2) & (3,3) & \ldots \\
\vdots &\vdots &\vdots & \ddots \\
};
\begin{scope}[transparency group, fill opacity=0.5,]
\draw[->-=.6] (m-1-1.north east) -- (m-1-1.south west) node[rlbl] {1};
\draw[->-=.5] (m-1-2.north east) -- (m-2-1.south west) node[llbl] {3} node[rlbl] {2};
\draw[->-=.3] (m-1-3.north east) -- (m-3-1.south west) node[llbl] {6} node[base,pos=0.5] {5} node[rlbl] {4};
\end{scope}
\end{tikzpicture}
\]
\end{frame}
\end{document}
Zarko
- 296,517
-
1
-
1@Zarko,it seems that the first line is not parallel to the second and third one. – Marian G. Aug 15 '18 at 05:45
-
1@MarianG., really? is this eventual discrepancy (i don't see any) very important? – Zarko Aug 15 '18 at 05:57
-
1@Zarko, the graphical discrepancy is a highly subjective issue. In fact, the proportions of the box around the pair (1,4) are not the same as the proportions of the rectangle box containing the pairs on the positions a_11, a_12, a_21 and a_22. Therefore, the angles of the gray lines will not be identical. For testing purposes, write
\draw[->-=.5,line width=44pt] (m-1-2.north east) -- (m-2-1.south west) node[llbl] {3} node[rlbl] {2};to see the small excursion(s). – Marian G. Aug 15 '18 at 07:10 -
1The first pair of integers at the top left is (1,1) and not (1,4). The arrow is superimposed on the 1 and gives the impression of a 4. – AndréC Aug 15 '18 at 13:32


