10

How do I get the text does not break the line? I have

\begin{tikzpicture}
\node[align=left,text width=3cm] {Contemplando a contemporaneidade};
\end{tikzpicture}

enter image description here

but i need

enter image description here

lockstep
  • 250,273
Regis Santos
  • 14,463
  • 3
    Is there a reason why you can't just increase the text width? (By the way, your example code does not break the line if I put it into a article or minimal document. Do you set anything that influences the font size?) – Jake Mar 25 '11 at 22:41

4 Answers4

10

Or don't specify the text width at all, just add a line break at the appropriate position.

\node[align=left] {Contemplando a\\contemporaneidade};
Torbjørn T.
  • 206,688
5

Instead of using align=left, you can use align=flush left. This seems to do exactly the same as align=left, but without the hyphenation.

\node[align=flush left,text width=3cm] {Contemplando a contemporaneidade};

I found this trick here: Manual/automatic line breaks and text alignment in TikZ nodes

JorenV
  • 205
3

Increase the value for text width conveniently.

Gonzalo Medina
  • 505,128
3

We could use \hyphenchar\font as a global switcher; =1 turning on hyphenation, =-1 preventing hyphenation.

\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{tikz}
\usepackage[english]{babel}
\begin{document}
\begin{tikzpicture}
\node[align=left,text width=2cm,draw] {Contemplando a contemporaneidade};
\end{tikzpicture}
\begin{tikzpicture}
\node[align=left,text width=2cm,draw] {%
  \hyphenchar\font=-1 % 1 or -1
  Contemplando a contemporaneidade
  };
\end{tikzpicture}
\hyphenchar\font=1 % 1 or -1
Regular document. Regular document. Regular document. Regular document. Regular document. Regular document. Regular document. 
\end{document}

mwe

Malipivo
  • 13,287
  • Is the \hyphenchar\font=1 necessary to restore hyphenation, or is the \hyphenchar\font=1 actually localized? I ask because you called it a global switcher. At first glance, it seems to me that it would be a change valid only within the tikzpicture's scope. – Jonathan Komar Jan 14 '16 at 14:36
  • @macmadness86 I am not 100% sure, but I think that I tried % \hyphenchar\font=1 and it wasn't working well. I am not TeXing these days, so I cannot try more experiments, I am sorry about that. – Malipivo Jan 21 '16 at 21:38