1

I'm sorry if I'm using incorrect terminology, I'm pretty new to LaTeX.

My question is: how would one recreate image such as:

enter image description here

That is, basically, how does one create these lines with labels?

1

2 Answers 2

4

A solution with tikz.

Remember to put some \vspace{...} before and after, because with the overlay option, the tikzpicture has zero size, look at this answer for a more detailed explanation.

\documentclass{book}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{tikzmark, calc}
\begin{document}
    A solution with Ti\emph{k}Z:

    \vspace{4ex}
    {\Large
    \begin{equation*}
        \tikzmark{sum}\sum_{\tikzmark{ind}i=\tikzmark{un}1}^{\tikzmark{up}n} = {x}_{i}\tikzmark{elem}
    \end{equation*}}
    \begin{tikzpicture}[overlay,remember picture]
        \draw ($(pic cs:sum)+(.1,.15)$) --  ($(pic cs:sum)+(-.85,.15)$) 
            node[anchor=east] 
                {\footnotesize summation sign};
        \draw ($(pic cs:ind)+(.07,-.08)$) |- ($(pic cs:ind)+(-1,-.3)$) 
            node[anchor=east,text width=3cm] 
                {\vspace{-1ex}
                 \begin{flushright} 
                     \footnotesize 
                     index of \\ 
                     summation 
                 \end{flushright}};
        \draw ($(pic cs:up)+(.09,.25)$) |- ($(pic cs:upb)+(6.6,2.1)$) 
            node[text width=7cm, anchor=west] 
                {\vspace{-1ex}
                 \begin{flushleft} 
                     \footnotesize 
                     stopping point \\ 
                     upper limit of summation 
                 \end{flushleft}};
        \draw ($(pic cs:elem)+(.1,.15)$) -- ($(pic cs:elem)+(.9,.15)$) 
            node[anchor=west, text width=3cm] 
                {\footnotesize typical element};
        \draw ($(pic cs:un)+(.09,-.08)$) |- ($(pic cs:un)+(1,-.3)$) 
            node[anchor=west, text width=7cm] 
                {\vspace{-1ex}
                 \begin{flushleft} 
                     \footnotesize 
                     starting point\\ 
                     lower point of summation 
                 \end{flushleft}};
    \end{tikzpicture}

    \vspace{7ex}
    Some \textbackslash\texttt{vspace} before and after is necessary.
\end{document}

enter image description here

5
  • Brillant. (+1 and thanks so much!)
    – user85571
    Commented Feb 21, 2017 at 20:24
  • @VanDerWarden You're welcome! I think it could be done even in a more elegant way, without the calc library, for example.
    – CarLaTeX
    Commented Feb 21, 2017 at 20:40
  • @VanDerWarden Remember to put some \vspace{...} before and after my code, look at the note I added to my answer.
    – CarLaTeX
    Commented Feb 21, 2017 at 21:44
  • Maybe it's a silly question, but... what's so unelegant about using the calc library?
    – user85571
    Commented Feb 21, 2017 at 23:50
  • @VanDerWarden Simply because in this case it's not necessary. I think you can correcty position the nodes putting the lenghts after below, right, etc. or things like that. But I'm a beginner and this solution is quicker for me... Don't forget to accept the answer you prefer!
    – CarLaTeX
    Commented Feb 22, 2017 at 6:23
0

There is also a solution based on pstricks:

    \documentclass[12pt]{article}
    \usepackage{amssymb,amsmath}
    \usepackage{xcolor}
    \usepackage[T1]{fontenc}
    \usepackage{pstricks,pst-node,pst-blur}
    \begin{document}
    \begin{tabular}{rcl}
     &
     \ovalnode[shadow=true,blur=true]{stop}{\tiny\begin{tabular}{l}
     stopping point\\
     upper limit of summation
     \end{tabular}} &\\[1cm]
     \ovalnode[shadow=true,blur=true]{sign}{\tiny summation sign}
     & $\rnode[c]{sum}{\displaystyle\sum\limits_{\rnode[c]{i}{\scriptstyle i}=\rnode[c]{1}{\scriptstyle 1}}
     ^{\rnode[c]{n}{\scriptstyle n}}} \rnode[c]{x}{x_i}$ &
     \ovalnode[shadow=true,blur=true]{typ}{\tiny typical element}
     \\[1cm]
     \ovalnode[shadow=true,blur=true]{index}{\tiny\begin{tabular}{r}
     index of\\
     summation
    \end{tabular}} & &
     \ovalnode[shadow=true,blur=true]{start}{\tiny\begin{tabular}{l}
     starting point\\
     lower point of summation
    \end{tabular}}
    \end{tabular}
    \ncarc{->}{stop}{n}
    \ncarc{->}{sign}{sum}
    \ncarc{->}{typ}{x}
    \ncarc{->}{sign}{sum}
    \ncarc{->}{start}{1}
    \ncarc{->}{index}{i}
    \end{document} 
    \endinput

enter image description here

You must log in to answer this question.