documentclass[border={5mm}]{standalone} \usepackage{tikz}  \begin{document} \begin{tikzpicture}[scale=1,     default rectangle/.style={rectangle, draw=black,thin, minimum size=1cm},         ] %---------------------------------------------------------------------------- % fuel Assembly %---------------------------------------------------------------------------- % Water around the assembly   \foreach \x in {-10,-5}{     \foreach \y in {-1,4}{       \draw[black,very thin, fill=blue!50!white] (\x,\y) rectangle (-10,4);  % side plate left         \foreach \x in {-9.9,-9.4}{          \foreach \y in {-0.9,3.9}{                  \draw[black,very thin, fill=gray!20!white] (\x,\y) rectangle (-9.4,3.9);  % side plate right             \foreach \x in {-5.6,-5.1}{             \foreach \y in {-0.9,3.9}{                     \draw[black,very thin, fill=gray!20!white] (\x,\y) rectangle (-5.1,3.9);  % 19 fuel plates                  \foreach \position in {(-5.6,-0.8)}{                  \draw[black,very thin, fill=gray!50!white] \position rectangle (-9.4,-0.7);                     }                 }               }              }            }          }        }   \end{tikzpicture}  \end{document}   I am trying to reproduce the picture of a fuel assembly below. My problem is to repeat the 19 plates of the assembly using the loops, i.e. \foreach. Is there a way to avoid repeating the use of \foreach loop for all the 19 plates? Basically I need to build the plate once and just repeat it 19 times as in the attached picture. Thanking you in advance for your assistance.
121355
I am trying to write the code to draw the picture below in TikZ. My code is necessarily long with lots of \foreach loops. Could you please give guidance on how to reproduce this picture in TikZ.
6517
I have a graph. This is my code.    \documentclass[10pt]{article}     \usepackage{pgf,tikz}     \usetikzlibrary{arrows,patterns}     \pagestyle{empty}      \definecolor{ttqqcc}{rgb}{0.2,0,0.8}     \definecolor{ffqqtt}{rgb}{1,0,0.2}     \definecolor{ttqqff}{rgb}{0.2,0,1}     \definecolor{uququq}{rgb}{0.25,0.25,0.25}      \begin{document}      \begin{tikzpicture}[line cap=round,line join=round,&gt;=triangle 45,x=1.0cm,y=1.0cm]      \draw[-&gt;] (-3.63,0) -- (3.67,0);     \foreach \x in {-3,-2,-1,1,2,3}       \draw[shift={(\x,0)}] (0pt,2pt) -- (0pt,-2pt)          node[below] {\footnotesize $\x$};     \draw[color=black] (3.48,0.07) node [anchor=south west] { $x$};      \draw[-&gt;] (0,-1.93) -- (0,5.57);     \foreach \y in {-1,1,2,3,4,5}       \draw[shift={(0,\y)}] (2pt,0pt) -- (-2pt,0pt)          node[left] {\footnotesize $\y$};     \draw[color=black] (0.06,5.19) node [anchor=west] { $y$};      \draw (0pt,-10pt) node[right] {\footnotesize $0$};      \clip(-3.63,-1.93) rectangle (3.67,5.57);     \draw[pattern color=ffqqtt,pattern=north east lines,fill opacity=0.1, smooth,samples=50,domain=0:1.0]      plot(\x,{\x^4-4*\x^2+3}) -- (1,0) -- (0,0) -- cycle;     \draw[pattern color=ttqqcc,pattern=crosshatch,fill opacity=0.1, smooth,samples=50,domain=1.0:1.7320508075688772]      plot(\x,{\x^4-4*\x^2+3}) -- (1.73,0) -- (1,0) -- cycle;      \begin{scope}[xscale=-1]     \draw[pattern color=ffqqtt,pattern=north east lines,fill opacity=0.1, smooth,samples=50,domain=0:1.0]        plot(\x,{\x^4-4*\x^2+3}) -- (1,0) -- (0,0) -- cycle;     \draw[pattern color=ttqqcc,pattern=crosshatch,fill opacity=0.1, smooth,samples=50,domain=1.0:1.7320508075688772]        plot(\x,{\x^4-4*\x^2+3}) -- (1.73,0) -- (1,0) -- cycle;     \end{scope}      \draw[smooth,samples=100,domain=-3.6342419080068153:3.665758091993186] plot(\x,{(\x)^4-4*(\x)^2+3});      \fill [color=uququq] (-1.73,0) circle (1.5pt);      \fill [color=uququq] (-1,0) circle (1.5pt);      \fill [color=uququq] (1,0) circle (1.5pt);      \fill [color=uququq] (1.73,0) circle (1.5pt);      \end{tikzpicture}     \end{document}   When I see the DVI output DVI, I have    And if I look at the PDF file, I have
3072
I want to create a rectangle with tikz and fill it with a predefined image.  For example the following line fill the rectangle with a color. How can I fill with my images instead?  \fill[color=sthlmRed] (0, 4cm) rectangle(\paperwidth, 0.5\paperheight);
103395
I was quite impressed by the figures generated by TikZ and wanted to try TikZ to generate a few figures (please see the attached image drawn using an external WYSWYG program). When I tried to reproduce the figures myself using TikZ I found it very difficult to control the shapes in required positions. What is the simplest method to draw!these figures using TikZ?
10190
As far as I can understand this should draw the same set of five edges in exactly the same way.  The first set of edges are positioned correctly.  But the second set of edges is horribly aligned.  On my screen, of the \foreach edges, the bottom horizontal one is shifted to the right, the others seems to start ok and then end up further from the center of the pentagon then they should.  Aside from wondering how to fix the alignment, I would also love to understand why this only happens inside a \foreach.  I can "solve" this by first drawing the nodes with minimum size=0mm, and then at the very end redrawing them with 2mm, but that seems less than optimal...  \documentclass{beamer}  \usepackage{calc,ifthen} \usepackage{amsthm,amsmath,amssymb} \usepackage{tikz}  \begin{document}  \frame{ \begin{tikzpicture} \def\r{2cm}  \foreach \t in {0,...,4} {   \node[circle,draw, outer sep=0mm, inner sep=0mm, minimum size=2mm] (a\t) at ({90+\t*72}:\r) {} ; }  % draw the edges of the pentagon in a silly way % draws edges from node-center to node-center \draw (a0) edge (a1) ; \draw (a1) edge (a2) ; \draw (a2) edge (a3) ; \draw (a3) edge (a4) ; \draw (a4) edge (a0) ;  % draw the edges of the pentagon in a better way % draws edges from node-something to node-something-else \foreach \t in {0,...,4} {   \pgfmathsetmacro{\s}{mod(\t+1,5)}   \draw (a\t) edge (a\s) ; }  \end{tikzpicture} }  \end{document}
112494
I am new to TeX and I am trying to create a document which has regular text, paragraphs etc and also a timing diagram somewhere in between. I am using the TikZ timing package.  Here is an example of what I am trying to do.  Create a section. Write some text. Add a timing diagram. End section and on to the next section.  Here is the code sample I tried.  \documentclass{article} \usepackage{tikz-timing}[2009/12/09] \usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength{\PreviewBorder}{1mm} \pagestyle{empty}  \begin{document} % % Defining foreground (fg) and background (bg) colors \definecolor{bgblue}{rgb}{0.41961,0.80784,0.80784}% \definecolor{bgred}{rgb}{1,0.61569,0.61569}% \definecolor{fgblue}{rgb}{0,0,0.6}% \definecolor{fgred}{rgb}{0.6,0,0}% %   \begin{section}  1.  Timing diagram of SR Flip Flop     Here is the timing diagram of SR flip flop.     \begin{tikztimingtable}[     timing/slope=0,         % no slope     timing/coldist=2pt,     % column distance     xscale=2.05,yscale=1.1, % scale diagrams     semithick               % set line width   ]   \scriptsize clock     &amp; 7{C}                              \\   S                     &amp; [fgblue] .75L h 2.25L H LLl       \\   R                     &amp; [fgblue]  1.8L .8H 2.2L 1.4H 0.8L \\   Q                     &amp;          L .8H 1.7L 1.5H LL       \\   $\overline{\mbox{Q}}$ &amp;          H .8L 1.7H 1.5L HH       \\   Q                     &amp; [fgred]  HLHHHLL                  \\   $\overline{\mbox{Q}}$ &amp; [fgred]  LHLLLHH                  \\ \extracode  \makeatletter  \begin{pgfonlayer}{background}   % Draw shaded backgrounds   \shade [right color=bgblue,left color=white]      (7,-8.45) rectangle (-2,-4.6);   \shade [right color=bgred,left color=white]      (7,-12.8) rectangle (-2,-8.6);   % Add background grid lines   \begin{scope}[gray,semitransparent,semithick]     \horlines{}     \foreach \x in {1,...,6}       \draw (\x,1) -- (\x,-12.8);     % similar: \vertlines{1,...,6}   \end{scope}   % Add labels   \node [anchor=south east,inner sep=0pt]     at (7,-8.45) {\tiny clocked};   \node [anchor=south east,inner sep=0pt,fgred]     at (7,-12.8) {\tiny positive edge triggered};  \end{pgfonlayer} \end{tikztimingtable}% % \end{section}  \end{document}   I am expecting the pdf to show the text first and then the timing diagram, but only the timing diagram is being generated.  Can somebody please help me?  Thanks
119693
I'm trying to create a fine flowchart that is a bit complicated. Therefore I need a block for a predefined process and a connector block as well as a data block. Can someone help me? In comment is what I'd like to see in my code to keep my code nicely arranged. The rest of the code is a simple example for the Tikz site.  \documentclass{article}  \usepackage[latin1]{inputenc} \usepackage{tikz} \usetikzlibrary{shapes,arrows} \begin{document} \pagestyle{empty}   % Define block styles \tikzstyle{decision} = [diamond, draw, fill=blue!20,      text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt] \tikzstyle{block} = [rectangle, draw, fill=blue!20,      text width=5em, text centered, rounded corners, minimum height=4em] \tikzstyle{line} = [draw, -latex'] \tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,     minimum height=2em]  %\tikzstyle{subroutine} = [draw,rectangle split, rectangle split         horizontal,rectangle split parts=3,minimum height=1cm]  %\tikzstyle{connector} = [draw,circle,...] %\tikzstyle{data} = [draw, trapezium, ...]  \begin{tikzpicture}[node distance = 2cm, auto]     % Place nodes     \node [block] (init) {initialize model};     \node [cloud, left of=init] (expert) {expert};     \node [cloud, right of=init] (system) {system};     \node [block, below of=init] (identify) {identify candidate models};     \node [block, below of=identify] (evaluate) {evaluate candidate models};     \node [block, left of=evaluate, node distance=3cm] (update) {update     model};     \node [decision, below of=evaluate] (decide) {is best candidate     better?};     \node [block, below of=decide, node distance=3cm] (stop) {stop};     % Draw edges     \path [line] (init) -- (identify);     \path [line] (identify) -- (evaluate);     \path [line] (evaluate) -- (decide);     \path [line] (decide) -| node [near start] {yes} (update);     \path [line] (update) |- (identify);     \path [line] (decide) -- node {no}(stop);     \path [line,dashed] (expert) -- (init);     \path [line,dashed] (system) -- (init);     \path [line,dashed] (system) |- (evaluate); \end{tikzpicture}   \end{document}
72387
TeX Code  \documentclass{standalone} \usepackage{tikz}  \begin{document}  \begin{tikzpicture}    \coordinate (A) at (0, 0);   \coordinate (B) at (2, 3);    \node[draw,minimum width=10mm] at (A) {};   \node[draw,minimum width=10mm] at (B) {}; \end{tikzpicture}  \end{document}   How such path can be drawn using Tikz?
12719
How to draw a perpendicular line from "P" to segment "AB"?    Here is the code:  \documentclass{standalone} \usepackage[utf8]{inputenc} \usepackage{tikz,tkz-euclide,xcolor,graphicx} \usetkzobj{all}  \begin{document} \tikz{ \coordinate(A)at(0,0); \coordinate(B)at(5,0); \coordinate(P)at(3.7896542,3);  \draw[thick](A)--(B);  \tkzDrawPoint[color=red](A)  \tkzLabelPoint[below=2pt](A){$A$} \tkzDrawPoint[color=red](B)  \tkzLabelPoint[below=2pt](B){$B$}   \tkzDrawPoint[fill=yellow](P)  \tkzLabelPoint[above=2pt](P){$P$} }  \end{document}
100396
Background and desired functionality  Rectangles can be drawn with tikz in a number of ways, one way of doing so is to define a rectangle node as follows:  \node (rectangle) [draw, rectangle] {A rectangle}; % Strictly speaking, rectangle is not needed in the [] as nodes are rectangular by default   A useful feature of this is that, as a node, it has anchor points around it such as rectangle.north, rectangle.south west and so on.  Another way is to draw a rectangle path, like this:  \draw (0,0) rectangle (3,2);   I would like to be able to use this second path-based method* but also be able to have (some) named anchors on the path.  Approach from the time of asking  MWE:  The method I had for this is demonstrated by the following MWE (inspired by  and later improved by ):  \documentclass{report}  \usepackage{tikz}  \begin{document}  \begin{tikzpicture}      \draw         (0,0)             coordinate [xshift=-{0.5\pgflinewidth},yshift=-{0.5\pgflinewidth}] (rectangle south west)         rectangle             coordinate (rectangle center)         (3,2)             coordinate [xshift={0.5\pgflinewidth},yshift={0.5\pgflinewidth}] (rectangle north east)         edge [draw=none]             coordinate (rectangle north)         (rectangle north east -| rectangle south west)     ;  \end{tikzpicture}  \end{document}   Obviously this only defines anchors for center, north, north east, and south west, but it can be fairly easily extended to provide south, east, west, north west and south east (as demonstrated in ).  Caveat:  As pointed out by Andrew Stacey in , there was a slight discrepancy between the positioning of these pseudo-anchor coordinates and the anchors on a normal rectangular node. The edge-based solution above originally placed the pseudo-anchors exactly on the coordinates of the rectangle whereas on a rectangular node they would be placed at the outside edge of the lines of the rectangle. Although this was only likely to cause issues with thick line widths I have now added some x/yshifting to the above code to compensate.  The following image shows the difference in anchor positioning between standard node rectangles, the original edge-based solution (without x/yshifting) and the above (revised) edge-based solution (with x/yshifting). The line widths for the lower pictures are set to 0.5cm.    Node rectangle labelling code to illustrate the key to the colours (and for the generally curious):  % styling yoinked from Altermundus' answer \tikzset{dot/.style={circle,fill=#1,inner sep=0,minimum size=4pt}} \node [dot=red] at (rectangle.south west) {}; \node [dot=blue] at (rectangle.center) {}; \node [dot=purple] at (rectangle.north east) {}; \node [dot=green] at (rectangle.north) {}; \node [dot=orange] at (rectangle.north west) {}; \node [dot=yellow] at (rectangle.south) {}; \node [dot=brown] at (rectangle.south east) {}; \node [dot=black] at (rectangle.east) {}; \node [dot=pink] at (rectangle.west) {};   Back to the question  Is there a neater/better way to establish node-anchor-like points on a rectangle path* than the method given in the MWE above?  * = An equivalent drawing method that also allows specifying a rectangle by corner coordinates would be more than acceptable!
65999
Ok so I have been trying to draw this figure:     I have made it till the above diagram. The three captions that I made in the topmost picture is what that is remaining. 1. The outer boundary of the rectangle should also be colored blue or some color.  2. The small circles should be labeled with a matrix.  3. The rectangle should be filled with horizontal lines  Here is the code for what I have done:      \documentclass{article} % say \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw  (0,5) node (yaxis) [above] {$y$} |- (5,0) node (xaxis) [right] {$x$}; \draw (-0.5,0) -- (4,0); \draw (0,-0.5) -- (0,4); \definecolor{mycolor}{RGB}{178,181,255} \filldraw[fill=mycolor] (0,0) rectangle (2,2); \filldraw [cyan] (0,2) circle [radius=2pt]; \filldraw [cyan] (2,0) circle [radius=2pt];  \end{tikzpicture} \end{document}   Any help would be appreciated.
95450
Here is the minimum working example:  \documentclass{article} \usepackage{tikz} \usepackage{float} \usepackage{listings} \usepackage{color} \usepackage{textcomp} \usetikzlibrary{shapes,positioning} \begin{document} \centering \begin{tikzpicture}   \node[draw] (PersonLocation Graph) {     \begin{minipage}{.85\linewidth} \begin{lstlisting}[language=XML,escapechar=!]   &lt;collection name=PersonLocation BiMap&gt;   &lt;edge&gt;    &lt;ref&gt;//collection[name=Locations]/loc[name=XXYY]   ! \tikz \node[shape=circle,draw](srchead) {H};!   &lt;/ref&gt;   &lt;ref&gt;//collection[name=Persons]/person[id=4564]   ! \tikz \node[shape=circle,draw](deshead) {E};      %(srchead) edge[&lt;-&gt;, bend left] (deshead.south);    !     &lt;/ref&gt;    &lt;/edge&gt;   ...   ...   ...   &lt;/collection&gt; \end{lstlisting} \end{minipage}  }; \end{tikzpicture} \end{document}   I want to draw an edge from node H to E. I tried  using statement srchead) edge[&lt;->, bend left] (deshead.south); (commented out in the code). Thanks in advance for your input.
113508
I've been creating a flow chart using the template I found here:    Please see the code below:  \documentclass{article} \usepackage[latin1]{inputenc} \usepackage{tikz} \usetikzlibrary{shapes,arrows} % Define block styles \tikzstyle{decision} = [diamond, draw, fill=blue!20,      text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt] \tikzstyle{block} = [rectangle, draw, fill=blue!20,      text width=5em, text centered, rounded corners, minimum height=4em] \tikzstyle{line} = [draw, -latex'] \tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,     minimum height=2em] \begin{document} \begin{tikzpicture}[node distance = 2cm, auto]     % Place nodes          \node [cloud] (a) {a};         \node [block, right of = a, node distance =5cm] (b) {b};         \node [decision, below of = b] (c) {c};         \node [block, below of = c, node distance = 3cm] (d) {d};         \node [decision, below of = d, node distance = 3.2cm] (e) {e};         \node [block, right of = e, node distance = 3.2cm] (f) {f};         \node [decision, below of = e] (g) {g};         \node [block, left of = g, node distance = 3.2cm] (h) {h};         \node [decision, below of = g, node distance = 3.5cm] (i) {i};         \node [block, left of = i, node distance = 3.2cm] (j) {j};         \node [block, right of = i, node distance = 3.5cm] (k) {k};      % Draw edges     \path [line] (a) -- (b);     \path [line] (b) -- (b);     \path [line] (b) -- node [near start] {yes} (d);     \path [line] (d) -- (e);     \path [line] (e) -- node [near start] {no} (f);     \path [line] (f) |- (b);     \path [line] (e) -- node [near start] {yes} (g);     \path [line] (g) -- node [near start] {no} (h);     \path [line] (h) |- (e);     \path [line] (g) -- node [near start] {yes} (i);     \path [line] (i) -- node [near start] {yes} (j);     \path [line] (j) -- (h);     \path [line] (i) -- node [near start] {no} (k);     \path [line] (k) -| (h); \end{tikzpicture} \end{document}   How can I create an arrow from k to h that doesn't intersect any of the other boxes or arrows?
99345
is there any particular way to get something similar to that in tikz with or without any packages?
59379
Am trying to draw a simple rectangle and there seems to be minor issue with two of the endpoints (f and d in the following). I tried line cap=rect as suggested by  but that did not seem to work.  The resulting image:    \documentclass{standalone} \setlength\PreviewBorder{5pt}%  \usepackage{tikz}  \newcommand*{\Width}{2.0} \newcommand*{\Height}{3.0} \newcommand*{\Depth}{1.0}  \begin{document} \begin{tikzpicture}%     \coordinate (A) at ( 0,       0,     \Depth);%     \coordinate (B) at (\Height,  0,     \Depth);%     \coordinate (C) at (\Height,  0,      0);%     \coordinate (D) at (\Height, \Width,  0);%     \coordinate (E) at ( 0,      \Width,  0);%     \coordinate (F) at ( 0,      \Width, \Depth);%     \coordinate (G) at (\Height, \Width, \Depth);%     \coordinate (H) at ( 0,       0,      0);%     %     \draw [blue, ultra thick,line cap=rect]%         (A) -- (B) -- (C) -- (D) -- (E) -- (F) -- cycle;%     \draw [blue, ultra thick,line cap=rect]%         (B) -- (G) -- (F) -- (E) -- (D) -- (G) -- cycle;%      \path (D)  [right] node {$d$};% Problem Point 1     \path (F)  [left ] node {$f$};% Problem Point 2 \end{tikzpicture}% \end{document}   This problem about  seems related, but I do not understand how to adapt that to my problem.
20941
As in , the code  \draw[step=0.5cm,color=gray] (-1,-1) grid (1,1);   gives me a nice finite 4x4 grid. But when I choose a different starting point, like  \draw[step=0.5cm,color=gray] (2,2) grid (4,4);   then the left and the bottom border of the grid disappears. What is the problem and how can I fix it so that I have all the borders? I know I can draw a rectangle there, but I assume there is some cleaner solution.
62350
I know that my effort below can be improved upon considerably.  In particular, there must be a way of shading the region in a single scope, as opposed to subdividing as I have done (thus necessitating a hidden gray boundary).  Neither am I fond of sample points, but this is where my research has led me.  Your constructive criticism is appreciated.    \documentclass{article} \usepackage{tikz} \begin{document}  \begin{tikzpicture} %graph \draw[draw=gray!50!white,fill=gray!50!white]      plot[smooth,samples=100,domain=0:1] (\x,{0}) --      plot[smooth,samples=100,domain=1:0] (\x,{1}); \draw[fill=gray!50!white] plot[smooth,samples=100,domain=1:2.71828] (\x,{ln(\x)}) --      plot[smooth,samples=100,domain=2.71828:1] (\x,{1}); \draw[domain=0:4] plot (\x,{1}); \draw[samples=100,domain=.25:4] plot (\x,{ln(\x)}) node[above left]{$y=\ln x$}; %coordinate grid \draw (-.5,0)--(4.5,0) node[right]{$x$}; \draw (0,-1.5)--(0,2.5) node[above]{$y$}; \foreach \x in {1,2,3,4}     \draw (\x,2pt)--(\x,-2pt) node[below] {$\x$}; \foreach \y/\ytext in {1,2}     \draw (2pt,\y)--(-2pt,\y) node[left] {$\y$};     %labels  \node at (.75,.5) {$\mathcal{D}$}; \end{tikzpicture}  \end{document}