0

I want to create a table in LATEX using tikz and I want to fill text into the table. I tried to do it with nodes, but the nodes overlap and so the text is not displayed correctly.

Is it possible to define a node such that it moves (automatically) below according to how much text I enter in the node above?

Here is my try:

\documentclass[a4paper, 11pt]{article}
\usepackage[a4paper,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{clrscode}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage{lmodern}
\usepackage{mathtools}
\usepackage{mdframed}
\usepackage{pgf}
\usepackage{tcolorbox}
\usepackage{tikz}
\usepackage{tikzpeople}
\usepackage[absolute,overlay]{textpos}
\usepackage{xcolor}    

\usetikzlibrary{arrows}
\usetikzlibrary{positioning} 
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{shapes.geometric}

\tikzstyle{process} = [rectangle, minimum width=3cm, text width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30]
\DeclareGraphicsExtensions{.pdf,.png,.jpg, .tif}

\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
%\fancyhead[LE,RO]{Overleaf}
%\fancyhead[RE,LO]{Guides and tutorials}
%\fancyfoot[CE,CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\familydefault}{\sfdefault}

\begin{document}
    \begin{tikzpicture}[node distance = 1cm]
        \node[process](step1){Step 1 \\ AAAAA \\BBBB \\CCCC};
        \node[process, below of=step1](ste2){Step 2};
    \end{tikzpicture}   

\end{document}
1

You can use the anchor like that:

\documentclass[tikz]{standalone}
\usepackage{xcolor}    

\usetikzlibrary{positioning}

\tikzstyle{process} = [rectangle, minimum width=3cm, text width=3cm, minimum height=1cm,
text centered, draw=black, fill=orange!30]


\begin{document}
    \begin{tikzpicture}[node distance = 1cm]
        \node[process](step1){Step 1 \\ AAAAA \\BBBB \\ CCC};
        \node[process, anchor=north](ste2) at (step1.south) {Step 2};
    \end{tikzpicture}   
\end{document}

EDIT: Alternative you can use the below = of option. Like that:

\documentclass[tikz]{standalone}
\usepackage{xcolor}    

\usetikzlibrary{positioning}

\tikzstyle{process} = [rectangle, minimum width=3cm, text width=3cm, minimum height=1cm,
text centered, draw=black, fill=orange!30]


\begin{document}
    \begin{tikzpicture}[node distance = 1cm]
        \node[process](step1){Step 1 \\ AAAAA \\BBBB \\ CCC};
        \node[process, below = 0cm of step1](ste2) {Step 2};
    \end{tikzpicture}   
\end{document}
  • 1
    Yes you are right but you can't use \node[process, below = of step1](ste2) {Step 2}; You have to define the gap width like that: \node[process, below = 0cm of step1](ste2) {Step 2}; – Ahrtaler Oct 18 at 9:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.