7

I got this kind of code in LaTeX using TikZ:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\begin{document}

\tikzstyle{block} = [draw,rectangle,fill=blue!50,text width=8em, text centered,minimum height=8mm,node distance=10em]
\tikzstyle{line} = [draw, -latex']



\begin{tikzpicture}
\tikzstyle{every node}=[font=\small]
\node [block, xshift=-3em](start){ST\_Category};
\node [block, right of=start, xshift=5em](process1){Process 1};
\end{tikzpicture}

\end{document}

Blocks got fixed size. All i want to achieve to have those block auto resize to fit longer text. So the block getting withders when text is longer. For example if in first block text will be "DASDASDADASDASDASDAS" it will go over the block borders which will look bad. I what those blocks to automatically expand when the text is longer.

Marco Daniel
  • 95,681
  • 1
    Welcome to TeX.sx! Your question was migrated here from [so]. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Jul 30 '12 at 17:20

1 Answers1

7

You are specifying that the with of the text is fixed via the option text width=8em. If you just eliminate that option, the box will re-size to the text.

Here is a comparison with text width=8em specified for the first line, but not for the second line:

enter image description here

Note:

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\begin{document}

\tikzstyle{block} = [draw, rectangle, fill=blue!50,, text centered, minimum height=8mm,node distance=10em] \tikzstyle{line} = [draw, -latex']

\tikzstyle{every node}=[font=\small]

\begin{tikzpicture}[text width=8em] \node block, xshift=-3em{DASDASDADASDASDASDAS}; \node block, right of=start, xshift=5em{Process 1}; \end{tikzpicture}

\begin{tikzpicture} \node block, xshift=-3em{DASDASDADASDASDASDAS}; \node block, right of=start, xshift=5em{Process 1}; \end{tikzpicture} \end{document}

Peter Grill
  • 223,288