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?


EDIT: Please see below:

\documentclass[12pt article]{article}


\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)};


share|improve this question
Please post a short example of the code that's causing you trouble. –  Count Zero Jan 7 '12 at 23:24
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
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
add comment

1 Answer

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
add comment

Your Answer


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.