2

I have tried building a 3D box to be something like

enter image description here

but I ended up with

enter image description here

from this code

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{positioning}
\usetikzlibrary{automata}
\usetikzlibrary{shapes.geometric}

\tikzset{%
    node distance=1cm,
    every node/.style={%
        align=center,
        fill=white,
        font=\small
    },
    elliptic state/.style={%
        state,
        ellipse,
        inner sep=0cm,
        minimum width=2cm
    },
}

\begin{document}

\begin{center}
\begin{tikzpicture}[node distance=2cm,font=\scriptsize]
\node[elliptic state,accepting] (s1) {$s_1$: $m_a,m_b,m_c$};
\node[elliptic state,below left=of s1] (s2) {$s_2$: $m_a,\neg m_b,m_c$};
\node[elliptic state,below=0.6cm of s1] (s3) {$s_3$: $m_a,m_b,\neg m_c$};
\node[elliptic state,below right=of s1] (s4) {$s_4$: $\neg m_a,m_b,m_c$};

\node[elliptic state,below=0.6cm of s2] (s5) {$s_5$: $m_a,\neg m_b,\neg m_c$};
\node[elliptic state,below right=of s2] (s6) {$s_6$: $\neg m_a,\neg m_b,m_c$};
\node[elliptic state,below=0.6cm of s4] (s7) {$s_7$: $\neg m_a,m_b,\neg m_c$};
\node[elliptic state,below=0.6cm of s6] (s8) {$s_8$: $\neg m_a,\neg m_b,\neg m_c$};

\path (s1) edge node {$b$} (s2);
\path (s1) edge node {$c$} (s3);
\path (s1) edge node {$a$} (s4);

\path (s2) edge node {$c$} (s5);
\path (s2) edge node {$a$} (s6);

\path (s3) edge node {$c$} (s5);
\path (s3) edge node {$c$} (s7);

\path (s4) edge node {$c$} (s6);
\path (s4) edge node {$c$} (s7);

\path (s5) edge node {$c$} (s8);

\path (s6) edge node {$c$} (s8);

\path (s7) edge node {$c$} (s8);
\end{tikzpicture}
\end{center}

\end{document}

As my nodes have more text, it is difficult to make a nice box that does not look messy.

How can I adjust my box to be a better looking box? My box is very flat, so I guess I need to make all the sides equal length and eventually reduce the top and bottom padding in each elliptic node since it takes up much space.

Are there any tikz libraries to automate creating such boxes so it looks a more neat?

3

1 Answer 1

3

How does this look? Just made some changes to node positioning and distance, added line breaks and reduced the fontsize.

enter image description here

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{positioning}
\usetikzlibrary{automata,shapes.geometric}

\tikzset{%
    node distance=1cm,
    every node/.style={%
        align=center,
        fill=white,
        font=\small
    },
    elliptic state/.style={%
        state,
        ellipse,
        inner sep=0cm,
        minimum width=2cm
    },
}

\begin{document}

\begin{center}
\begin{tikzpicture}[node distance=2cm]
\node[elliptic state,accepting] (s1) {$s_1$:\\ $m_a,m_b,m_c$};
\node[elliptic state,below left=of s1] (s2) {$s_2$:\\ $m_a,\neg m_b,m_c$};
\node[elliptic state,below=3cm of s1] (s3) {$s_3$:\\ $m_a,m_b,\neg m_c$};
\node[elliptic state,right=of s1] (s4) {$s_4$:\\ $\neg m_a,m_b,m_c$};

\node[elliptic state,below=3cm of s2] (s5) {$s_5$:\\ $m_a,\neg m_b,\neg m_c$};
\node[elliptic state,right=of s2] (s6) {$s_6$:\\ $\neg m_a,\neg m_b,m_c$};
\node[elliptic state,below=3cm of s4] (s7) {$s_7$:\\ $\neg m_a,m_b,\neg m_c$};
\node[elliptic state,below=3cm of s6] (s8) {$s_8$:\\ $\neg m_a,\neg m_b,\neg m_c$};

\path (s1) edge node {$b$} (s2);
\path (s1) edge node {$c$} (s3);
\path (s1) edge node {$a$} (s4);

\path (s2) edge node {$c$} (s5);
\path (s2) edge node {$a$} (s6);

\path (s3) edge node {$c$} (s5);
\path (s3) edge node {$c$} (s7);

\path (s4) edge node {$c$} (s6);
\path (s4) edge node {$c$} (s7);

\path (s5) edge node {$c$} (s8);

\path (s6) edge node {$c$} (s8);

\path (s7) edge node {$c$} (s8);
\end{tikzpicture}
\end{center}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .