1

Using the following code, can the red arrow and its text be inserted within a node at pos=.5 (beside the blue circle) of the blue line, instead of drawing it separately with a draw command

    \documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows, arrows.meta, positioning, calc, intersections, decorations.pathreplacing, decorations.pathmorphing, decorations.markings, shapes, shapes.misc, shapes.symbols, shapes.geometric, patterns}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
\begin{tikzpicture}[scale=.9, transform shape]
\draw [thick,-latex](0,0) -- (4,0) node [black, xshift=.93cm, yshift=0cm] {$Q$};
\draw [thick,-latex](0,0) -- (0,8) node [black, xshift=0cm, yshift=.3cm] {$P$};
\draw [ultra thick,blue] (0,7.5) -- +(-50:5cm) node [pos=.5, circle, draw, blue, fill=blue, scale=0.4]{};
\draw [thick,red,-latex'] (2.08,5.92) node [red, xshift=.2cm, yshift=.04cm]{x} -- +(-140:.4cm);
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

  • 1
    i show you how to do this with defining aligned pin in my answer to one of your previous question? you can also use simple pin. sorry, actually i don't understand your question well ... – Zarko Jul 14 '18 at 7:27
  • 1
    You can certainly do that, e.g. with path picture. However, I am struggling to understand what that should be good for. – user121799 Jul 14 '18 at 7:27
  • 2
    Use a pin for that. You don't need anything as fancy as the aligned pin style though, just a normal one. – Torbjørn T. Jul 14 '18 at 7:53
  • Would you please tell me the code for pinning the arrow! – Hany Jul 14 '18 at 8:26
  • @TorbjørnT., suggestion for aligned-pin is based on one of previous op question. there are also shown, how to use simple pin as i also mentioned in my comment. i thing that this question is duplicate. – Zarko Jul 14 '18 at 8:43
3

Ordinary pins can be found on p. 241 of the pgfmanual.

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows}
%\usetikzlibrary{arrows, arrows.meta, positioning, calc, intersections, decorations.pathreplacing, decorations.pathmorphing, decorations.markings, shapes, shapes.misc, shapes.symbols, shapes.geometric, patterns}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
\begin{tikzpicture}[scale=.9, transform shape]
\draw [thick,-latex](0,0) -- (4,0) node [black, xshift=.93cm, yshift=0cm] {$Q$};
\draw [thick,-latex](0,0) -- (0,8) node [black, xshift=0cm, yshift=.3cm] {$P$};
\draw [ultra thick,blue] (0,7.5) -- +(-50:5cm) node [pos=.5, circle, draw, blue,
fill=blue, scale=0.4,pin={[red,pin edge={red,thick,latex'-}]above right:x}]{};
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

  • Just one more modification please, can the pinned arrow be shifted x and y. I appreciate your answer very much. – Hany Jul 14 '18 at 11:07
  • 1
    @Hany It an but how much should it be shifted? If you do \draw [ultra thick,blue] (0,7.5) -- +(-50:5cm) node [pos=.5, circle, draw, blue, fill=blue, scale=0.4,pin={[red,xshift=4pt,pin edge={red,thick,latex'-}]above right:x}]{}; then there will be an additional xshift by 4pt. – user121799 Jul 14 '18 at 11:10
  • This shifted the text attached to the arrow, not the arrow itself – Hany Jul 14 '18 at 11:21
  • 1
    @Hany Do you want to shorten the arrow? Then try e.g. shorten <=5pt. If you want to move it, try shorten <=5pt,shorten >=-5pt or something along these lines. All of that goes into the curly brackets of pin edge={...}. – user121799 Jul 14 '18 at 11:25
  • That is what I want. – Hany Jul 14 '18 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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