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 have an expression "a = function(b)" inside a node. But "a =" and "function(b)" appear on separate lines. I can force the node to be wider, but this doesn't change how the writing inside is laid out. How can I fix this?

Thanks

EDIT: Please see below:

\documentclass[12pt article]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\begin{document}

\begin{tikzpicture}[node distance = 2cm, auto]

\tikzstyle{block} = [rectangle, draw, fill=blue!20, 
    text width=5em, text centered, rounded corners, minimum height=4em]

\node [block] (A) {Some writing, a = function(b)};

\end{tikzpicture}

\end{document}
share|improve this question
3  
Please post a short example of the code that's causing you trouble. –  Count Zero Jan 7 '12 at 23:24
1  
Did you use the text width option by any chance? Nevermind, I see that you do. It is simply due to the fact that your defined width is too narrow for it. –  percusse Jan 7 '12 at 23:35
4  
The width of the text block is defined by text width, so even if you increase the size of the node, that won't change the text. Can't you set text width to a larger value, e.g. 8em? Another option is perhaps to not set the text width, and define the line breaks manually, with `\\`. (Edit: Too late ...) –  Torbjørn T. Jan 7 '12 at 23:38
    
as already said it is the text width setting. so forcing it will result in a bad box warning. –  someonr Jan 7 '12 at 23:54

1 Answer 1

up vote 2 down vote accepted

If it's in math mode, you solve it by adding curly braces, such as

${a = function(b)}$

If it's in text mode, though I would use math mode, you could use \mbox:

\mbox{a = function(b)}

Both prevent the line break, also in TikZ nodes.

share|improve this answer
    
But I think there shouldn't be any reason for tikz to break the line if there is enough space (Matt said "I can force the node to be wider"). I think there might be some problem with his code... –  someonr Jan 7 '12 at 23:32
    
Thanks, your first suggestion sorted my problem. –  Matt Jan 7 '12 at 23:34

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.