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.

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.

share|improve this question

migrated from stackoverflow.com Jul 30 '12 at 17:18

This question came from our site for professional and enthusiast programmers.

1  
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. 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 Answer 1

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](start){DASDASDADASDASDASDAS};
\node [block, right of=start, xshift=5em](process1){Process 1};
\end{tikzpicture}


\begin{tikzpicture}
\node [block, xshift=-3em](start){DASDASDADASDASDASDAS};
\node [block, right of=start, xshift=5em](process1){Process 1};
\end{tikzpicture}
\end{document}
share|improve this answer
    
Why the xshifts? –  JLDiaz Jul 30 '12 at 17:24
    
@JLDiaz: Those are just left over from the original MWE. But you are right some of them are not necessary. –  Peter Grill Jul 30 '12 at 17:27

Your Answer

 
discard

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