1

Using the following code, is it possible to insert the long text (in the node) inside a framed box with certain background colour, with a certain defined width and a height that accommodates the long text.

    \documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{1}
\begin{tikzpicture}[scale=.9, transform shape]
\draw [thick,-latex](0,0) -- (6.2,0) node [black, xshift=.3cm, yshift=0cm] {$x$};
\draw [thick,-latex](0,0) -- (0,5) node [black, xshift=0cm, yshift=.3cm] {$u$};
\draw [ultra thick,blue] (0,2.84) -- +(-40:4.44cm) node [pos=.5,red] {x} node [pos=.5, xshift=4.8cm, yshift=.2cm] {very very very very very very very long long long long long long long text} node [pos=0,circle, draw, black, fill=black, scale=0.5]{}  node [pos=1,circle, draw, black, fill=black, scale=0.5]{};
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

to make it look like this

enter image description here

1
  • The answer by Zarko gives more control than the answer suggested by percusse. It controls the background colour, the frame colour, and the connection between the text and node position; which are not addressed by the answer suggested by percusse. – Hany Jul 10 '18 at 14:25
3
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{1}

\begin{tikzpicture}[
    dot/.style = {circle, fill, node contents={}},
    every pin/.append style = {pin distance=9mm, pin edge={black, semithick},
                               text width=24mm, fill=orange!20}
                    ]
\draw [thick,-latex](0,0) -- (6.2,0) node [black, xshift=.3cm, yshift=0cm] {$x$};
\draw [thick,-latex](0,0) -- (0,5) node [black, xshift=0cm, yshift=.3cm] {$u$};
\draw [ultra thick,blue] (0,2.84) --
    node [dot,pin=60:very very very very very very very long long long long long long long text] + (-40:4.44cm);
\end{tikzpicture}

\end{frame}
\end{document}

gives:

enter image description here

is this what you looking for?

in mwe above i define node style dot for black circle on curve, text is added as pin to this node- pin style among others contain text width=<width> option. this option automatically break long text into more lines (long as determined in <width>)

addedndum:

more control on pin and text anchors enables solutions provided in Qrrbrbirlbel answer on the question tikz-adjusting-pin-anchor. adoption to your question is:

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}

\begin{document}
\begin{frame}[fragile,t]
\frametitle{1}

\begin{tikzpicture}[
    dot/.style = {circle, fill, outer sep=0pt, node contents={}},
aligned pin/.style args={[#1]#2:#3}%
    {pin={[pin distance=9mm, pin edge={black, semithick, shorten >=-8pt},
           inner sep=0pt, label={[append after command={%
                node[text width=32mm, fill=orange!20, outer sep=0pt,%
                     at=(\tikzlastnode.#2),% position of pin
                     anchor=#1,% for node withpin text
                    ]{#3}}]center:{}}% for details see https://tex.stackexchange.com/questions/246995/
          ]#2:{}}%
    }
                    ]
\draw [thick,-latex](0,0) -- (6.2,0) node [black, xshift=.3cm, yshift=0cm] {$x$};
\draw [thick,-latex](0,0) -- (0,5) node [black, xshift=0cm, yshift=.3cm] {$u$};
\draw [ultra thick,blue] (0,2.84) --
    node [dot,aligned pin={[west]45:very very very very very very very long long long long long long long text}] + (-40:4.44cm);
\end{tikzpicture}

\end{frame}
\end{document}

which gives:

enter image description here

2
  • I appreciate very much your effort. Just one comment please, can the joining black line position be modified (ex. to the left edge of the text instead of the bottom edge; or to the center of the box instead of the corner). – Hany Jul 10 '18 at 14:10
  • 1
    @Hany, see addendum. it enable more control on pin text positioning. – Zarko Jul 10 '18 at 16:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.