1

I'm pretty new to Latex and i've just found out about tikZ. I'm barely able to make a triangle and angle. I just wanted to ask if you can tell me how to start with he following project:https://en.wikipedia.org/wiki/Stellar_parallax#/media/File:Stellarparallax_parsec1.svg

The Preamble:

\usepackage{appendixnumberbeamer}

\usepackage{booktabs}
\usepackage[scale=2]{ccicons}

\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,bending,decorations.markings,intersections,angles,quotes,babe        l,lindenmayersystems,plotmarks}
\pgfdeclarelindenmayersystem{A}{%
  \symbol{F}{\pgflsystemstep=0.6\pgflsystemstep\pgflsystemdrawforward}
  \rule{A->F[+A][-A]}
}
\tikzset{
    arc arrow/.style args={%
    to pos 1 with length 2}{
    decoration={
    markings,
     mark=at position 0 with {\pgfextra{%
     \pgfmathsetmacro{\tmpArrowTime}{2/(\pgfdecoratedpathlength)}
     \xdef\tmpArrowTime{\tmpArrowTime}}},
    mark=at position {1-\tmpArrowTime} with {\coordinate(@1);},
    mark=at position {1-2*\tmpArrowTime/3} with {\coordinate(@2);},
    mark=at position {1-\tmpArrowTime/3} with {\coordinate(@3);},
    mark=at position {1} with {\coordinate(@4);
    \draw[-{Stealth[length=2,bend]}]       
    (@1) .. controls (@2) and (@3) .. (@4);},
    },
 postaction=decorate,
 },bent arrow/.style={arc arrow=to pos #1 with length 2mm},
 pics/strange bar/.style={code={\draw[thick] (-#1,0) -- (#1,0);}}
}

\usepackage{xspace}
\newcommand{\themename}{\textbf{\textsc{metropolis}}\xspace}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage{animate}
\usepackage{selinput}
\SelectInputMappings{adieresis={ä}, germandbls={ß}}

The Frame:

\begin{frame}[fragile]
\hspace{2cm}
\begin{tikzpicture}[font=\sffamily]
    \draw[name path=A] (0,5) coordinate(TL) -- (0,0);
    \draw[bent arrow/.list={0.125,0.625}] (0,0) circle[x radius=2cm,y radius=0.5cm];
    \draw[fill=blue] (-2,0) circle[radius=1.5mm];
    \draw[fill=yellow] (0,0) circle[radius=2mm];
    \draw[name path=B] (-2,0) -- (1,5) coordinate(TR);
    \draw[fill=pink,name intersections={of=A and B,by=I}] (I) circle[radius=1.5mm]node[left=3pt]{Near star};
    \pic [angle radius=1cm,angle eccentricity=.5,draw,"p" alias=p] {angle = TR--I--TL};
     \draw[pink,latex-,thick] (p) -- ++ (1,-1) node[right,align=left,text=black]{parallax angle\\ = 1``};
    \draw ([xshift=5mm]I) -- ++ (3,0) coordinate (R1) pic[rotate=45]{strange bar=0.3}
    -- (0,0-|R1) coordinate (R2)  pic[rotate=45]{strange bar=0.3}node[midway,above,sloped] {1 parsec}
    -- (2.5,0); 
    \draw (-2,-0.3) -- (-2,-2) pic[rotate=45]{strange bar=0.3} -- (0,-2)node[midway,above]{1 AE} pic[rotate=45]{strange bar=0.3}
    -- (0,-0.3);
    \draw[bent arrow/.list={0.125,0.625},thin] (0,5)  circle[x radius=1cm,y radius=0.15cm];
    \draw[fill=pink] (TR) circle[radius=1mm] (-1,5) circle[radius=1mm];
    \draw[pink,latex-,thick,shorten >=1mm] (TR) -- ++ (0.5,-1) node[right,align=left,text=black] (AP) {apparent parallax\\ motion near star};
    \draw[pink,latex-,thick,shorten >=1mm] (-1,5) -- (AP.west);
\end{tikzpicture}
\end{frame}

1 Answers1

3

Welcome to TeX-SE! This is to give you a start. I apologize in advance if I have misinterpreted some elements.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta,bending,decorations.markings,intersections,angles,quotes}
% https://tex.stackexchange.com/a/430239/121799
\tikzset{% inspired by https://tex.stackexchange.com/a/316050/121799
    arc arrow/.style args={%
    to pos #1 with length #2}{
    decoration={
        markings,
         mark=at position 0 with {\pgfextra{%
         \pgfmathsetmacro{\tmpArrowTime}{#2/(\pgfdecoratedpathlength)}
         \xdef\tmpArrowTime{\tmpArrowTime}}},
        mark=at position {#1-\tmpArrowTime} with {\coordinate(@1);},
        mark=at position {#1-2*\tmpArrowTime/3} with {\coordinate(@2);},
        mark=at position {#1-\tmpArrowTime/3} with {\coordinate(@3);},
        mark=at position {#1} with {\coordinate(@4);
        \draw[-{Stealth[length=#2,bend]}]       
        (@1) .. controls (@2) and (@3) .. (@4);},
        },
     postaction=decorate,
     },bent arrow/.style={arc arrow=to pos #1 with length 2mm},
     pics/strange bar/.style={code={\draw[thick] (-#1,0) -- (#1,0);}}
}

\begin{document}
\begin{tikzpicture}[font=\sffamily]
 \draw[semithick] (80:12) arc(80:100:12) node[midway,above]{Distant stars};
 \fill foreach \X in {82,86,90,92,95,99} {(\X:12) circle[radius=1.5pt] };
 \draw[name path=A] (0,11.8) coordinate(TL) -- (0,0);
 \draw[bent arrow/.list={0.125,0.625}] (0,0) circle[x radius=2cm,y radius=0.5cm];
 \draw[fill=blue] (-2,0) circle[radius=2mm];
 \draw[fill=yellow] (0,0) circle[radius=2mm];
 \draw[name path=B] (-2,0) -- (1,11.8) coordinate(TR);
 \draw[fill=pink,name intersections={of=A and B,by=I}] (I) circle[radius=2mm]
 node[left=3pt]{Near star};
 \pic [angle radius=1cm,angle eccentricity=1.3,draw,"p" alias=p] {angle = TR--I--TL};
 \draw[pink,latex-,thick] (p) -- ++ (1,-0.5) node[right,align=left,text=black]{parallax angle};
 \draw ([xshift=5mm]I) -- ++ (3,0) coordinate (R1) pic[rotate=45]{strange bar=0.6}
 -- (0,0-|R1) coordinate (R2)  pic[rotate=45]{strange bar=0.6}
 node[midway,above,sloped] {1 parsec}
 -- (2.5,0); 
 \draw (-2,-0.3) -- (-2,-2) pic[rotate=45]{strange bar=0.6} -- (0,-2)
 node[midway,above]{1 AU} pic[rotate=45]{strange bar=0.6}
 -- (0,-0.3);
 \draw[bent arrow/.list={0.125,0.625},thin] (0,11.8)  circle[x radius=1cm,y radius=0.15cm];
 \draw[fill=pink] (TR) circle[radius=1mm] (-1,11.8) circle[radius=1mm];
 \draw[pink,latex-,thick,shorten >=1mm] (TR) -- ++ (0.5,-1) 
 node[right,align=left,text=black] (AP) {apparent parallax\\ motion near star};
 \draw[pink,latex-,thick,shorten >=1mm] (-1,11.8) -- (AP.west);
\end{tikzpicture}
\end{document}

enter image description here

  • 1
    Wow! Thank you very much –  Mar 14 '19 at 06:08
  • I get following error: I do not know the key '\tikz"p�lias', to which you passed 'p', and I am going to ignore it. So the name of the angle isn't shown and the arrow (paralax angle) points on the sun. But thank you very much for providing the whole code! –  Mar 14 '19 at 19:11
  • @TirolaleinLeine Do you compile the above document when you get the error or do you get it when you embed the tikzpicture in another document? In the latter case, does the error go away if you add \usetikzlibrary{babel} to the preamble of your document? –  Mar 14 '19 at 19:58
  • its embeded in my document and i still have the error when in add \usetikzlibrary{babel}. I tried to post my whole preamble but its too long. Something special you would need? –  Mar 15 '19 at 13:17
  • @TirolaleinLeine In that case you may just ask a new question with a minimal example (a minimal document with the preamble of the embedding document and the code of the picture you are using). –  Mar 15 '19 at 13:20
  • I haved added the preamble and the code of the frame to the question. –  Mar 15 '19 at 14:05
  • 1
    @TirolaleinLeine You need a fragile frame: \begin{frame}[fragile] – samcarter_is_at_topanswers.xyz Mar 15 '19 at 14:10
  • @samcarter What does it change? –  Mar 15 '19 at 14:11
  • 2
    @TirolaleinLeine It makes your code compilable by preventing some voodoo tha beamer normally does with all content of a frame – samcarter_is_at_topanswers.xyz Mar 15 '19 at 14:13
  • 1
    @TirolaleinLeine In this particular case the problem probably are the # in the tikzset – samcarter_is_at_topanswers.xyz Mar 15 '19 at 14:15
  • @Samcarter yeah now its prefect. –  Mar 15 '19 at 14:27
  • 1
    @TirolaleinLeine What happened here is a good example that illustrates why many users here ask for an MWE (minimal working example). If you would have provided one (even if the tikzpicture was very minimal), anyone answering it would circumvented the pitfalls (and also made sure that the thingy fits on a beamer slide). Changing these things afterwards is a bit cumbersome, and many users are not really willing to do that. –  Mar 15 '19 at 15:09
  • 1
    @marmot I recently cleaned my crystal ball for the upcoming spring and now it works again for such problems :) – samcarter_is_at_topanswers.xyz Mar 15 '19 at 15:25