Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Place boundary of two adjacent nodes on top of each other

If I place two nodes adjacent to each other the resulting boundary between the nodes is doubled making it more thick than other boundarys. Is it possible to place them on top of each other in order to keep the original thickness?

Here my code and below some example pictures:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{figure}
\begin{center}
\begin{tikzpicture}

\tikzstyle{node} = [draw, rectangle, minimum width=1cm]
\node [node] (n_one) {node 1};
\node [node, right = 0cm of n_one.north east, anchor = north west] (n_two) {node 2};

\end{tikzpicture}
\end{center}
\end{figure}

\end{document}

Overall look

Closer look

like image 981
Elias Avatar asked Sep 07 '25 02:09

Elias


1 Answers

You can shift the right node by one line width:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{figure}
\begin{center}
\begin{tikzpicture}

\tikzstyle{node} = [draw, rectangle, minimum width=1cm]
\node [blue,node] (n_one) {node 1};
\node [red,node, right = -\the\pgflinewidth of n_one.north east, anchor = north west] (n_two) {node 2};

\end{tikzpicture}
\end{center}
\end{figure}

\end{document}

enter image description here

Or you could draw only a single node:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.multipart} 

\begin{document}

\begin{figure}
\begin{center}
\begin{tikzpicture}
\node[
  rectangle split, 
  rectangle split parts=2,
  draw, 
  rectangle split horizontal,
  rectangle split part align={center, top, bottom}
] at (0,0)  {node 1\nodepart{two}node 2};
\end{tikzpicture}
\end{center}
\end{figure}

\end{document}

enter image description here

like image 128
samcarter_is_at_topanswers.xyz Avatar answered Sep 10 '25 09:09

samcarter_is_at_topanswers.xyz