1

I am having trouble obtaining a single border between two adjoining node shapes with tikz. When I use a thick border, it leads to an overlapping double border at the connection of two nodes.
How would one avoid this?

I currently try using the positioning library as well as the chain library.

I currently have this enter image description here

Which I produce with the following code.

\documentclass{standalone} % standalone 
\usepackage{graphicx}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{tikz}
\usetikzlibrary{chains,shapes,positioning}

\begin{document}

\tikzstyle{b1} = [rectangle,
                  fill = red!50,
                  draw = black, thick,
                  fill opacity = 0.5, text opacity = 1]
\tikzstyle{b2} = [rectangle,
                  fill = blue!50,
                  draw = black, thick,
                  fill opacity = 0.5, text opacity = 1]               

\begin{tikzpicture}[auto,node distance=1cm and 0cm,every node/.style={font=\small}]

\node(A)[b1] at (0,0) {A};
\node(B)[b2,right=of A]{B};

\end{tikzpicture}

\begin{tikzpicture}[start chain,node distance=0mm,every node/.style={font=\small}]

\node[on chain,b1] {A};
\node[on chain,b2] {B};

\end{tikzpicture}

\end{document}
1
  • 1
    Tray, if outer sep=0pt as option of your rectangles help.
    – Zarko
    Nov 8, 2015 at 22:50

1 Answer 1

2

I will extend my comment to answer:

\documentclass[border=3mm]{standalone} % standalone
\usepackage{tikz}

\usetikzlibrary{chains,shapes,positioning}
\tikzset{
every node/.style = {rectangle, draw=black, thick,
                     fill opacity = 0.5, text opacity = 1,
                     font=\small, 
                    outer sep=0pt,% <-- this eliminate your problem
                     },
b1/.style = {fill=red!50},
b2/.style = {fill=blue!50}
        }

    \begin{document}
\begin{tikzpicture}[auto,node distance=1cm and 0cm]
    \node(A)[b1] {A};
    \node(B)[b2,right=of A]{B};
\end{tikzpicture}

\begin{tikzpicture}[start chain=going right,node distance=0mm]
    \node[on chain,b1] {A};
    \node[on chain,b2] {B};
\end{tikzpicture}
    \end{document}

Above code (which is based on slightly shorten your MWE) generate:

enter image description here

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.