3

I've been using Tikz and created the following graph with that code :

\documentclass{article}  
\usepackage{tikz}  
\usepackage{amssymb}
\usetikzlibrary{arrows}  
\begin{document}  
\begin{center}
\begin{tikzpicture}
    \draw [fill=white!60!white,opacity=1] (-2.99,5.98) -- (2.99,5.98) -- (0,0) -- cycle;
    \draw [fill=white!30!white,opacity=1,] (0,6) circle (2.99cm and 0.6cm) node [above] {$A_T$};
    \draw [fill=blue!60!white,opacity=1] (-1.49,2.98) -- (1.49,2.98) node [left=1cm, below = 1.5 cm] {\color{blue} $V_0$} -- (0,0) -- cycle;
    \draw [fill=blue!30!white,opacity=1,] (0,3) circle (1.49cm and 0.3cm);
    \draw (0,0) -- (0,3) [line width = 1.3pt] node [left, below = 1cm] {$h_0$};
    \draw (0,3) -- (-1.49, 3) [line width = 1.3pt] node [right = 1cm, above] {$r_0$};
    \draw (3mm,6mm) arc [start angle=50, end angle=126, radius = 5mm, line width = 2pt] node [above = 6pt, right] {$\theta$};
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

I'm really not good at using it and it could be terribly coded. What I've been trying to do is change the text and make it larger so that it's readible. Also I've been trying to position the text for h_0 in the middle and left but it only takes one argument into account. What am I doing wrong?

Could anyone please help me with editing the text? Thanks

4

Perhaps this?

\documentclass{article}  
\usepackage{tikz}  
\usepackage{amssymb}
\usetikzlibrary{arrows}  

\begin{document}  

\begin{center}
\begin{tikzpicture}
    \draw [fill=white!60!white,opacity=1] (-2.99,5.98) -- (2.99,5.98) -- (0,0) -- cycle;
    \draw [fill=white!30!white,opacity=1,] (0,6) circle (2.99cm and 0.6cm) node [above] {$A_T$};
    \draw [fill=blue!60!white,opacity=1] (-1.49,2.98) -- (1.49,2.98) -- (0,0) -- cycle;
    \node[font=\color{blue}] at (-0.4,1.7) {$V_0$};
    \draw [fill=blue!30!white,opacity=1,] (0,3) circle (1.49cm and 0.3cm);
    \draw[line width = 1.3pt]  (0,0) -- node[right] {$h_0$} (0,3) -- node[above] {$r_0$} (-1.49, 3)  ;
    \draw (3mm,6mm) arc [start angle=50, end angle=126, radius = 5mm, line width = 2pt] node[near end,above] {$\theta$};
\end{tikzpicture}
\end{center}

\end{document}

If you want to increase the font size, you can pass the option font=\Large (or any other font switch) to a node.

enter image description here

Along a path you can place several nodes and can control the position along the path using several modifiers: midway, near start, near end, pos=<value> (there are more possibilities; please refer to the PGF manual):

\documentclass{article}  
\usepackage{tikz}  

\begin{document}  

\begin{center}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (7,6);
\draw 
  (a) -- 
    node[midway] {midway} 
    node[near end] {near end} 
  (b) 
    node[near start] {near start} 
    node[pos=0.333] {pos=0.333};
\begin{scope}[xshift=4cm]
\coordinate (a) at (0,0);
\coordinate (b) at (7,6);
\draw 
  (a) -- 
    node[midway,left] {midway, left} 
    node[near end,right] {near end, right} 
  (b) 
    node[near start,below=8pt] {near start,below=8pt} 
    node[pos=0.333,above=6pt] {pos=0.333,above=6pt};
\end{scope}
\end{tikzpicture}
\end{center}

\end{document}

enter image description here

  • Thanks, brilliant answer. Is pos a parameter from 0 to 1 along the line? – user88595 May 20 '14 at 13:39
  • 2
    @TAllieri You're welcome. If the <value> for pos is between 0 and 1, the position lies in the segment joining the two points, If it is greater than one or less then zero, it will lie on the line, but outside the segment. – Gonzalo Medina May 20 '14 at 13:43

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.