I don't really get the question so I hope this is what you wanted. If you include a full document (such that we copy paste and see the problem on our systems) things are much more easier.
Here, you can change the default setting within a scope but your block
style had a node distance
which was resetting every time it is issued. I've made it 2mm such that we can see the difference easier.
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,shapes.geometric,positioning}
\begin{document}
\begin{tikzpicture}[decision/.style={diamond, draw, text width=4.5em, text badly centered, node distance=3.5cm, inner sep=0pt},
block/.style ={rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em, minimum height=2em},
cloud/.style ={draw, ellipse, minimum height=2em},
line/.style ={draw,-latex'},
node distance = 1cm,
auto]
\node [block] (1st) {1st};
\node [block, right= of 1st] (2nd1) {2nd1};
\begin{scope}[node distance=2mm and 10mm]%Here we change it for everything inside this scope
\node [block, above= of 2nd1] (2nd2) {2nd2};
\node [block, below= of 2nd1] (2nd3) {2nd3};
\node [block, right= of 2nd1] (3rd1) {3rd1};
\node [block, above= of 3rd1] (3rd2) {3rd2};
\node [block, above= of 3rd2] (3rd3) {3rd3};
\end{scope}
\node [block, below= of 3rd1] (3rd4) {3rd4};
\node [block, below= of 3rd4] (3rd5) {3rd5};
\path [line] (1st) -- (2nd1);
\path [line] (2nd1) -- (2nd2);
\path [line] (2nd1) -- (2nd3);
\path [line] (2nd2) -- (3rd3);
\path [line] (2nd1) -- (3rd1);
\path [line] (1st) -- (2nd1);
\end{tikzpicture}
\end{document}
I just had a similar question marked as a duplicate of this one. Here is the link. Unfortunately, the answer posted here was not marked as an answer and OP indicated it as not working. Credit for this approach goes to @symbol-1.
As noted by @percusse here and @cfr and @symbol-1 in the link, the result will be viewer dependent. Examples of viewer differences provided below the code.
Here is modified from the OP and @percusse's answer using transparency group=knockout
in the scope
environment options:
\documentclass[tikz]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\path[pattern=crosshatch dots light steel blue](-2,-2) rectangle (2,2);
\begin{scope}[transparency group=knockout]
\draw (-2,0) to node(aaaaa){} (2,0);
\path (aaaaa) node[fill,opacity=0,text opacity=1]{aaaaa};
\end{scope}
\end{tikzpicture}
\end{document}
You can change the background to anything you like and no other changes are necessary. If you change the text to be longer/short, the background opacity will resize accordingly - i.e. no changes other than the label name.
In some PDF viewers (e.g. SumatraPDF, TeXworks previewer, etc.):
In other PDF viewers (e.g. Adobe Acrobat):
The PDF is the same in both cases. I simply took a screenshot of it opened in two different PDF viewers. It seems the background is affected as well, but the focus here is the transparency.
Also, here is an example of an additional node with text going vertically to illustrate what happens with transparency group=knockout
with multiple nodes:
\documentclass[tikz]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\path[pattern=crosshatch dots light steel blue](-2,-2) rectangle (2,2);
\begin{scope}[transparency group=knockout]
\draw (-2,0) to node(aaaaa){} (2,0);
\path (aaaaa) node[fill,opacity=0,text opacity=1]{aaaaa};
\draw (0,-2) to node(bbbbb){} (0,2);
\path (bbbbb) node[fill,opacity=0,text opacity=1]{\rotatebox[origin=c]{90}{bbbbb}};
\draw (-2,-0.35) to node(ccccc){} (2,-0.35);
\path (ccccc) node[fill=red,text opacity=1]{ccccc};
\end{scope}
\end{tikzpicture}
In some PDF viewers (e.g. SumatraPDF, TeXworks previewer, etc.):
In other PDF viewers (e.g. Adobe Acrobat):
You will notice that whichever item is last with opacity=0
takes precedence over the previous item(s). If you flip the aaaaa
and bbbbb
lines and nodes (i.e bbbbb
occurs first), for example, you'll see this (in the conforming PDF viewers):
opacity=0
also takes precedence over other items which do not have opacity. For example, if we move the ccccc
node/lines first within the tikzpicture
, here is the result:
Just remember! If your picture is very complicated and you open it in an old or (transparency) non-conforming PDF viewer, it will not be what you expect.
If you have many nodes with transparency and you do not like the overlapping issue, you will need to adjust the order of the nodes, xshift
and yshift
, and/or place the nodes in different positions completely.
Best Answer
I am not doing any work today!