TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

Consider the code below:

\documentclass[convert = false, border = 1cm]{standalone}
  \node[font = \scriptsize] at (-3.5, 4) {Position of $S_2$ when};
  \node[font = \scriptsize] at (-3.5, 3.7) {$S_1$ reaches $C$};

I used two nodes to write short explanation of a point in a figure I am constructing. However, I had to play around with the set up so they weren't spaced vertically too far a part and the second node was centered on the content of the first node. Is there a better way to this?

enter image description here

share|improve this question

marked as duplicate by Jake tikz-pgf Mar 16 '15 at 13:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Yes, \node […,align=center] at (…) {Position of $S_2$ when \\ $S_1$ reaches $C$};. – Qrrbrbirlbel Jul 11 '13 at 22:55
@Qrrbrbirlbel thanks. I didn't know I could use \\ in a node. – dustin Jul 11 '13 at 23:00
up vote 7 down vote accepted

As Qrrbrbirlbel pointed, you can use \\ to break lines inside a node if you also use align option. Without it, \\ has no effect as is shown in top node below.

If you don't want to insert \\ every time, you can combine text width and align options. With them, latex will break lines according its rules. You'll find some examples below.




\node[draw] (a) {Position of $S_2$ when \\ $S_1$ reaches $C$};

\node[draw,text width=3cm, below=of a] (b) {Position of $S_2$ when \\ $S_1$ reaches $C$};

\node[draw,align=center, below=of b] (c) {Position of $S_2$ when \\ $S_1$ reaches $C$};

\node[draw,text width=3cm, align=right, below=of c] (d) {Position of $S_2$ when $S_1$ reaches $C$};


enter image description here

share|improve this answer

It is sad that PSTricks cannot do it without parbox or its variants. The following is with PSTricks.



\rput(5,2){\parbox{10cm}{\centering Karl's students do not care about dashing patterns.\\ Karl's students do not care about arrow tips.}}


enter image description here

share|improve this answer

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