1

Yes, there are in fact 2 questions but I hope they are close enough to be related.

Hi all, I'm trying to draw a flow chart using tikz. When I want to put a itemize list in the node solb I couldn't make the spacing of the list to be single and left aligned as I wish.

Also when I add the description to the arrow I don't know how to fix the description north and center to the horizontal part of the arrow.

It'd be the best if someone can help me together on these 2 things. Thanks a lot.

My MWE is here.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{varwidth}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}

\tikzstyle{rec} = [
    rectangle,
        minimum width = 1cm, minimum height = 1cm,
    text centered,
    draw = black, fill = white]
\tikzstyle{recw80} = [
    rectangle]
\tikzstyle{recw30} = [
    rectangle,
        minimum width = 1cm, minimum height = 1cm,
    text width = 3cm,
    draw = black, fill = white]
\tikzstyle{arrow} = [thick,->,>=stealth]

\begin{document}

\makebox[\textwidth][c]{\begin{tikzpicture}[node distance=2cm]

\node (start) [rec] {Hi};
\node (q1) [recw80, below of=start, yshift=-0.5cm] {};
\node (solb) [recw30, right of=q1, xshift=6.5cm] {
    \begin{varwidth}{\linewidth}\begin{itemize}
        \item Point 1,
        \item Point 2, or
        \item Point 3.
    \end{itemize}\end{varwidth}};

\draw [arrow] (solb) |- node[anchor=south] {How are you?} (start);

\end{tikzpicture}}

\end{document}

1 Answer 1

1

Welcome! Please note that \tikzstyle is deprecated. (I also do not understand the purpose of the \makebox.)You can use the enumitem package to customize you itemize environment, use align=left, and use pos=0.75 to have the edge label in the middle of the horizontal stretch. I also recommend using the positioning library, i.e. instead of below of, say, use below=<distance> of. In your example this allows us to eliminate the auxiliary q1 node.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{varwidth}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{rec/.style={
    rectangle,
        minimum width = 1cm, minimum height = 1cm,
    text centered,
    draw = black, fill = white},
recw80/.style={
    rectangle},
recw30/.style={
    rectangle,
        minimum width = 1cm, minimum height = 1cm,
    text width = 3cm,align=left,
    draw = black, fill = white},
arrow/.style={thick,->,>=stealth}}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[node distance=2cm]
\node (start) [rec] {Hi};
\node (solb) [recw30,below right=0.5cm and 6.5cm of start] {
    \begin{varwidth}{\linewidth}\begin{itemize}[nosep,leftmargin=*]
        \item Point 1,
        \item Point 2, or
        \item Point 3.
    \end{itemize}\end{varwidth}};

\draw [arrow] (solb) |- node[pos=0.75,above] {How are you?} (start);

\end{tikzpicture}
\caption{A Ti\emph{k}Z picture.}
\end{figure}
\end{document}

enter image description here

9
  • makebox to make the whole flow chart align at center (but I forgot which question in this site gave me this idea).
    – Yuki.F
    Dec 22, 2019 at 6:28
  • @Yuki.F OK,I see. If you put the picture in a figure, you can achieve this with \centering.
    – user194703
    Dec 22, 2019 at 6:29
  • \centering where? Just after \begin{figure}?
    – Yuki.F
    Dec 22, 2019 at 6:35
  • @Yuki.F Yes, that's right.
    – user194703
    Dec 22, 2019 at 6:36
  • Doesn't work...
    – Yuki.F
    Dec 22, 2019 at 6:37

You must log in to answer this question.

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