Now I write some code to draw the graph. However, the graph is too large, I just want to put it in the left half of the document. So how to set the font size and location of the graph?

Also, I want to change the and-or-gate to diamond or bigoplus in the graph like

enter image description here

I don't known how to draw it,would someone help me? The code below is taken from TeXample fault tree example:

% Gates and symbols style
    and/.style={and gate US,thick,draw,rotate=90,
    or/.style={or gate US,thick,draw,rotate=90,
        minimum width=0.7cm},
    tr/.style={buffer gate US,thick,draw,rotate=90,
        anchor=east,minimum width=0.8cm},
% Label style
    label distance=3mm,
    every label/.style={blue},
% Event style
    event/.style={rectangle,thick,draw,text width=2cm,
        text centered,font=\sffamily,anchor=north},
% Children and edges style
    edge from parent/.style={->,very thick,draw=black!70},
    edge from parent path={(\tikzparentnode.south) -- ++(0,-1.05cm)
            -| (\tikzchildnode.north)},
    level 1/.style={sibling distance=5cm,level distance=1.4cm,
            growth parent anchor=south,nodes=event},
    level 2/.style={sibling distance=5cm},
    level 3/.style={sibling distance=3cm},
    level 4/.style={sibling distance=2cm}
%%  For compatability with PGF CVS add the absolute option:
%   absolute

  \begin{scope}[xshift=-15cm,yshift=-5cm,very thick]
%% Draw events and edges
    \node (g1) [event] {No flow to receiver}
         child{node (g2) {No flow from Component B}
            child {node (g3) {No flow into Component B}
               child {node (g4) {No flow from Component A1}
                  child {node (t1) {No flow from source1}}
                  child {node (b2) {Component A1 blocks flow}}
               child {node (g5) {No flow from Component A2}
                  child {node (t2) {No flow from source2}}
                  child {node (b3) {Component A2 blocks flow}}
            child {node (b1) {Component B blocks flow}}
%% Place gates and other symbols
%% In the CVS version of PGF labels are placed differently than in PGF 2.0
%% To render them correctly replace '-20' with 'right' and add the 'absolute'
%% option to the tikzpicture environment. The absolute option makes the
%% node labels ignore the rotation of the parent node.
   \node [or]   at (g2.south)   [label=-20:G02] {};
   \node [and]  at (g3.south)   [label=-20:G03] {};
   \node [or]   at (g4.south)   [label=-20:G04] {};
   \node [or]   at (g5.south)   [label=-20:G05] {};
   \node [be]   at (b1.south)   [label=below:B01]   {};
   \node [be]   at (b2.south)   [label=below:B02]   {};
   \node [be]   at (b3.south)   [label=below:B03]   {};
   \node [tr]   at (t1.south)   [label=below:T01]   {};
   \node [tr]   at (t2.south)   [label=below:T02]   {};
  • Please state the source of the code even if the code is free to share/copy, it doesn't hurt. – percusse Jul 30 '12 at 13:32
  • I've updated my answer, Please let me know if something like that is what you need. – Gonzalo Medina Jul 30 '12 at 23:58
  • @GonzaloMedina thanks for your answer, sorry that I don't know if the answer satisfy, I should to accept it, and even have no idea of how to accept an answer, so sorry about it. – sweetyBaby Jul 31 '12 at 1:39
  • @sweetyBaby You're welcome. Regarding the "accepting answers" issue, no problem at all (the same happens to a lot of users). Now you know how to accept answers ;-) – Gonzalo Medina Jul 31 '12 at 1:43

Below there's one possibility. The main points:

  1. First the tikzpicture code was written (modify the code according to your needs).
  2. Then, the \resizebox command (from the graphicx package) was used to scale down the tikzpicture width to 0.5\textwidth (use the desired width and/or height).
  3. Then the scaled figure was place inside a wrapfigure environment from the wrapfig package to allow text wrapping.

    \usepackage{lipsum}% just to generate text for the example
    oplus/.style={draw,circle, text width=2.5em,fill=blue!20,
      postaction={path picture={% 
          (path picture bounding box.south west) -- (path picture bounding box.north east) 
          (path picture bounding box.north west) -- (path picture bounding box.south east);}}},
    block/.style = {rectangle, draw, fill=blue!20, 
        text width=5em,align=center, minimum height=3em},
    decision/.style = {diamond, draw, fill=blue!20, 
        text width=4.5em,inner sep=0pt},
    line/.style = {draw,thick, -latex'},
    node distance=1.8cm and 1cm
    % Place nodes
    \node [block] (a) {text};
    \node [block, below of=a] (b) {text};
    \node [decision, below of=b] (c) {};
    \node [block, below left of=c,xshift=-1cm, yshift=-0.3cm] (cl) {text};
    \node [block, below right of=c,xshift=1cm, yshift=-0.3cm] (cr) {text};
    \node [oplus, below of=cl] (cla) {};
    \node [block, below of=cla] (clb) {text};
    % Draw edges
    \path [line] (a) -- (b);
    \path [line] (b) -- (c);
    \path [line] (c) -| (cl) node [near start,anchor=south] {if};
    \path [line] (c) -| (cr) node [near start,anchor=south] {else};
    \path [line] (cl) -- (cla);
    \path [line] (cla) -- (clb);

enter image description here

  • aha, it is exactly what I need, however, there is error said <insert text> \par I can not find what the problem is in the code. – sweetyBaby Jul 31 '12 at 2:22
  • @sweetyBaby I need to see the actual code you are using; otherwise, it's impossible to say where the error might be. Can you upload the code somewhere and provide a link here? – Gonzalo Medina Jul 31 '12 at 2:24
  • OK, however, actually I just run your code ~ – sweetyBaby Jul 31 '12 at 2:28
  • @sweetyBaby my code runs OK in my system. Perhaps you are using outdated package(s)? Process the following test document: \documentclass{article} \usepackage{tikz} \begin{document} \pgfversion \end{document}. The output should print the PGF version used in your system; mine is 2.10; if you have an older version, you will need to update PGF (and perhaps all of oyur LaTeX system). – Gonzalo Medina Jul 31 '12 at 2:33
  • I have updated to 2.10, it works now!!! Thanks very much :-) – sweetyBaby Jul 31 '12 at 2:52

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.