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 a series of five image generated from a code that I wish to include one under the other in a figure. I would like to include labels on the left, right and bottom of each of them (left and bottom are identical to each of them).

However I would like the side labels to be rotated by 90°, but it seems that by default the point of rotation is the bottom right of the label on the left and bottom left for the one on the right. I cannot figure out how to rotate the label from its centre.

\PassOptionsToPackage{demo}{graphicx}
\documentclass[tikz]{standalone}

\begin{document}

\begin{tikzpicture}
\node[draw,
    label={[rotate=90]west:years $\rightarrow$},
    label={south:some other text},
    label={[rotate=-90,text=gray]east:OtherLabel}]
    {\includegraphics[width=12cm,height=2.4cm]{somefile1}};
\node[draw, yshift=2.5cm,
    label={[rotate=90]west:years $\rightarrow$},
    label={south:some other text},
    label={[rotate=-90,text=gray]east:OtherLabel}]
    {\includegraphics[width=12cm,height=2.4cm]{somefile2}};
\end{tikzpicture}

\end{document}

enter image description here

share|improve this question

1 Answer 1

up vote 7 down vote accepted

In PGF 2.10 manual, at page 195, about the placement of labels in nodes, it can be read:

The anchor that is chosen depends on the position of the border point that is chosen and its position relative to the center of the main node and on whether the transform shape option is set. In general, the choice should be what you would expect, but you may have to set the anchor yourself in difficult situations.

However no example is provided about how to do that, and the obvious option:

\node[draw, yshift=2.5cm,
    label={[anchor=south, rotate=90]west:years $\rightarrow$},
    ...

produces no effect.

So I would use instead extra nodes to label the main ones:

\begin{tikzpicture}
\node[draw,     
      label={south:some other text}] 
      (fig) {\includegraphics[width=12cm,height=2.4cm]{star.mps}};
\node[rotate=90, anchor=south] at (fig.west) {years $\rightarrow$};
\node[rotate=-90, anchor=south,text=gray] at (fig.east) {OtherLabel};
\end{tikzpicture}

Result

share|improve this answer
    
Yes indeed I had tried specifying the anchor to the label and like you I found that it didn't have any effect. I have been relunctant to use extra nodes as I wanted the code as simply as possible since I have 5 or 6 of these things of top of each other. Originally I also tried specifying the 2 common labels in the tikzset{every node/.style=...} thing but that didn't work anyway. –  ArTourter Dec 22 '12 at 16:25
    
label option internally adds an extra node, so in terms of software complexity, it will be the same. The syntax could be a bit more compact using label, but also a bit more obscure, so I don't think that using extra nodes was a bad idea. –  JLDiaz Dec 23 '12 at 12:55

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.