Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How make paragraph in TikZ. I use \parbox with \node

\node {\parbox[5cm]{text}};

but i need more options, alignment center or left or right, similar to text box. All in TikZ.

thanks.

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

There are some differences between TikZ versions.

  • With TikZ/pgf 2.10 use the alignment options given by Torbjorn: align=left etc. as options to \node. This doesn't work with TikZ 2.00. Example:

    \node[text width=3cm,align=right] {your text};
    
  • With TikZ/pgf 2.00 or below use text options to \node such as text centered, text ragged or text badly ragged. Example:

    \tikz \draw (0,0) node[text width=3cm,text ragged] {your text}
    
  • You may always use the vertical alignment options of \parbox and horizontal alignment declarations within the box.

    Syntax: \parbox[position][height][inner-pos]{width}{text}

    Example: \node{\parbox[t][6cm][c][5cm]{\centering your text}};

share|improve this answer
    
Thanks! And justify in TikZ/PGF 2.00? And break line with \\? –  Regis da Silva Dec 29 '10 at 14:46
    
@Regis da Silva: option text justified, and just use \\. Example: \node[text width=2cm,text justified] {Test\\text and more text}; –  Stefan Kottwitz Dec 29 '10 at 15:12
add comment

See section 16.4 in the TikZ manual. For example:

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum} % for creating dummy text
\begin{document}
\begin{tikzpicture}
  \node [text width=5cm,align=left] {\lipsum[1]};
\end{tikzpicture}
\end{document}

Other alignment options are center and right (naturally), as well as flush left, flush center and flush right, in which no hyphenation will occur, and justify.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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