7

This my tex code.

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[margin=15mm]{geometry}
\usetikzlibrary{shapes,arrows,fit,calc,positioning}


\begin{document}

\begin{figure}
\begin{tikzpicture}[thick,scale=0.5]
\tikzset{input/.style={}} 
\tikzset{block/.style={rectangle,draw}}
\tikzstyle{pinstyle} = [pin edge={to-,thick,black}]

\node [input, name=input] {};
\node [block, right=0.5cm of input,minimum width=1cm, minimum height=1cm] (a) {};
\node [block, right of=a,minimum width=1cm, minimum height=2cm,node distance=1.5 cm] (b) {};




\begin{scope}[->,>=latex]

\draw[->] (input) node[above]{\footnotesize{$Msg$}} -- (a);

\foreach \i [count=\xi from 0] in {2,...,-2}{%
\draw[->] ([yshift=\i * 0.4 cm]a.east) -- ([yshift=\i * 0.8 cm]b.west) node[right]{\footnotesize{$x_{\xi}$}} ;}

\end{scope}
\end{tikzpicture}
\end{figure}

\begin{tabular}{|r|r|}
\hline
$n$&$n!$\\
\hline
1&1\\
2&2\\
3&6\\
4&24\\
5&120\\
6&720\\
7&5040\\
8&40320\\
9&362880\\
10&3628800\\
\hline
\end{tabular}

\end{document}

Which produces

enter image description here

Two doubts:

  1. How to reduce the font size for x0,x1,...,x4?
  2. How to put the table on the RHS of the figure?
David Carlisle
  • 757,742
tikzlearner
  • 4,527

1 Answers1

6

If you want the table to be on the right hand side:

  • you need to make it part of the figure environment so that it floats with it, and
  • not leave a blank line between \end{tikzpicture} and \begin{tabular}, and
  • as per Alternumdus' comment use font= to change the size of the x0, x1, ..., x4.

Furthermore, you can:

to obtain:

enter image description here

Code:

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[margin=15mm]{geometry}
\usetikzlibrary{shapes,arrows,fit,calc,positioning}

\begin{document}

\begin{figure} \centering \raisebox{-0.5\height}{% \begin{tikzpicture}[thick,scale=0.5] \tikzset{input/.style={}} \tikzset{block/.style={rectangle,draw}} \tikzstyle{pinstyle} = [pin edge={to-,thick,black}]

\node [input, name=input] {}; \node [block, right=0.5cm of input,minimum width=1cm, minimum height=1cm] (a) {}; \node [block, right of=a,minimum width=1cm, minimum height=2cm,node distance=1.5 cm] (b) {};

\begin{scope}[->,>=latex] \draw[->] (input) node[above]{\footnotesize{$Msg$}} -- (a);

\foreach \i [count=\xi from 0] in {2,...,-2}{%
    \draw[->] 
            ([yshift=\i * 0.4 cm]a.east) -- 
            ([yshift=\i * 0.8 cm]b.west) 
        node[right, font=\footnotesize]{{$x_{\xi}$}} ;
}

\end{scope} \end{tikzpicture} }% \hspace{0.5cm} \begin{tabular}{|r|r|} \hline $n$&$n!$\ \hline 1&1\ 2&2\ 3&6\ 4&24\ 5&120\ 6&720\ 7&5040\ 8&40320\ 9&362880\ 10&3628800\ \hline \end{tabular}% \end{figure} \end{document}

Peter Grill
  • 223,288