TikZ의 노드에서 자동 단어 줄 바꿈?

TikZ의 노드에서 자동 단어 줄 바꿈?

TikZ내 계획을 단계별로 보여주는 순서도를 만드는 데 사용하고 있습니다 . 노드에서 단어 줄 바꿈이 자동으로 이루어지지 않는 것을 확인했습니다. 즉, 줄이 전체 페이지에 걸쳐 매우 길 수 있습니다.

MWE는 다음과 같습니다.

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{tikz}

\title{Your Paper}

\begin{document}
\maketitle

\begin{tikzpicture}[block/.style={draw, fill=white, rectangle, minimum width=0.95*\columnwidth, anchor=west}, font=\small]
    \node[block, minimum width=0.95\columnwidth, minimum height=1cm, fill=white, opacity=1, text opacity=1, rounded corners, thick](step1) at (0,0){};
    \node[below=0cm of step1.north, align=left]{\textbf{Step 1}: This is Step one, which is a very very very long sentence. I really hate it when it does not automatically do the wrapping.};
    \node[block, minimum width=0.95\columnwidth, minimum height=1cm, below right=0.9cm and 0cm of step1.south, fill=white, opacity=1, text opacity=1, rounded corners, thick](step2) at (0,0){};
    \node[below=0cm of step2.north, align=left]{\textbf{Step 2}: Step 2 is cute and short.};
    \draw[-stealth](step1.south)--(step2.north)node[pos=0.5, above=0cm]{};
\end{tikzpicture}


\end{document}

이는 다음과 같이 렌더링됩니다. 여기에 이미지 설명을 입력하세요

현재 해결 방법은 새 줄을 수동으로 삽입하는 것인데 이는 매우 번거롭습니다.

그러므로 나는 찾고 싶다.노드에서 자동 단어 줄 바꿈을 수행하는 우아한 방법입니다.TikZ.

답변1

align=<option>키를 설정했기 때문에 를 사용할 때 예상되는 자동 텍스트 줄 바꿈이 이루어지지 않았습니다 minimum width. text width(가 아닌 minimum width) 에 대한 적절한 값을 제공하십시오 . 그런 다음 align=<option>원하는 정렬을 제공합니다.

\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{tikz}

\title{Your Paper}

\begin{document}
\maketitle

\begin{tikzpicture}[
block/.style={
  draw, 
  fill=white, 
  text width=0.95*\columnwidth, 
  anchor=west,
  minimum height=1cm,
  rounded corners 
  }, 
font=\small
]
\node[block,align=left]
  (step1)
  {\textbf{Step 1}: This is Step one, which is a very very very long sentence. I really hate it when it does not automatically do the wrapping.};
\node[block,below=2cm of step1.north,align=center]
  (step2)
  {\textbf{Step 2}: Step 2 is cute and short.};
\draw[-stealth]
  (step1.south)--(step2.north)node[pos=0.5, above=0cm]{};
\end{tikzpicture}

\end{document}

여기에 이미지 설명을 입력하세요

또한 일부(분명히 불필요한) 노드를 억제하여 원본 코드를 단순화했습니다.

관련 정보