我想使用 tikz 在 LATEX 中创建一个表格,并想将文本填充到表格中。我尝试使用节点来实现,但节点重叠,因此文本无法正确显示。
是否可以定义一个节点,使其根据我在上面的节点中输入的文本量(自动)移动到下面?
这是我的尝试:
\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
您可以像这样使用锚点:
\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}
编辑:您也可以使用以下below = of
选项。就像这样:
\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}