Graphics, Figures & TablesBeginning Tikz questions

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
theo moore
Posts: 72
Joined: Thu Jan 15, 2009 3:16 pm

Beginning Tikz questions

Post by theo moore »

I'm just getting started with TikZ, and as you know, the learning curve is quite high. I'm hoping to keep this thread open so that I can ask miscellaneous (hopefully simple) questions as I go.

First question is, how would I place an arrowhead somewhere along a path?? For example,

Code: Select all

\draw [->, very thick, rounded corners=10pt, inner color = white, outer color = gray] 
    						(-1,0) 
    						.. controls (-0.8, -0.2) and (-0.8, -0.4).. (-0.8,-0.5)
						.. controls(-1.2, -1.2) and (1.5,-2) .. (0.8, 0)
						.. controls(0.8,0.5) .. (1,1)
						.. controls(1.6, 2) and (-2,2) .. (-1.2,0.2) 
							node[pos=0.2, right=0.5cm]{$\Gamma$}
						-- cycle;
I'd like to place an arrowhead around where the node is.

Another question. I'd like to wrap a lot of my Tikz figures into a subtly dotted rectangle. Obviously, I could use the \draw command for each figure, but this would be tiresome. I would have to figure out the dimensions for each figure.

Is there a command that can simply determine the lowest lower-left and highest upper-right points?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Beginning Tikz questions

Post by localghost »

For the first issue you should search the pgf/tikZ manual for "path decorations". Perhaps you will find something useful i the example gallery [1].

For the second issue I'm not aware of an automatism since the package reduces the actual image to minimal size.

[1] TikZ and PGF examples


Best regards
Thorsten
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

Beginning Tikz questions

Post by T3. »

theo moore wrote:Another question. I'd like to wrap a lot of my Tikz figures into a subtly dotted rectangle. Obviously, I could use the \draw command for each figure, but this would be tiresome. I would have to figure out the dimensions for each figure.

Is there a command that can simply determine the lowest lower-left and highest upper-right points?
You could use the predefined "current bounding box" node:

Code: Select all

\begin{tikzpicture}[execute  at  end  picture={\draw[dotted] (current bounding box.south west) rectangle (current bounding box.north east);}]
\draw (0,0) circle (1);
\end{tikzpicture}
Cheers,

Tomek
theo moore
Posts: 72
Joined: Thu Jan 15, 2009 3:16 pm

Beginning Tikz questions

Post by theo moore »

Thanks for the help. I found two solutions to the above problems. For the first one, you can use path decorations. For the second problem, there is actually a backgrounds library. So for example,

Code: Select all

\begin{tikzpicture}
[scale=1.5, tight background, background rectangle/.style = {draw=black, dotted,rounded corners=5ex}, show background rectangle]
\end{tikzpicture}
would put a dotted rectangle around my image :D

I have another question, this one about the organization of my TikZ pictures. I'd like to specify universal styles so that I could avoid having to repeat the same style over and over. For example, if I wanted all the arrows in my TikZ figures to be of the 'stealth' variety and of a certain size, how would I do that?
Post Reply