
Estou usando TikZ
para fazer um fluxograma demonstrando meu esquema passo a passo. Percebo que a quebra automática de palavras não é automática em um nó. Ou seja, a linha pode ser extremamente longa em toda a página.
O MWE é o seguinte.
\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}
que renderiza como
Minha solução atual é inserir manualmente uma nova linha, o que é muito problemático.
Desejo, portanto, encontraruma maneira elegante de conseguir a quebra automática de palavras em um nó deTikZ
.
Responder1
Você não estava obtendo a quebra automática de texto esperada que seria de se esperar align=<option>
, porque estava definindo a minimum width
chave. Forneça um valor apropriado para text width
(não para minimum width
); então align=<option>
fornecerá o alinhamento desejado:
\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}
Também fiz algumas simplificações no código original, suprimindo alguns nós (aparentemente desnecessários).