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.

Im using xscale to reduce the width of a node. This not only scales the shape but also the text. How can I x-scale the shape without the text?

  \node[mynode] (foo) [right=of ocr,fit={(ocr) (omr)},xshift=3cm,xscale=0.5] {FOO};
share|improve this question
1  
It would be good if you could make this into a full compilable example (starting from \documentclass). That would make it easier for people to try out the code and come up with solutions. As it is, everyone would have to spend time figuring out what [mynode] could be, that the positioning library is needed, and that two other nodes ocr and omr need to exist in the document. –  Jake Jul 11 '11 at 12:50
1  
You could scale the text back :-) using \scalebox{2}{FOO}. –  Martin Scharrer Jul 11 '11 at 12:52
    
@Martin: Is there an xscalebox? If yes, I think that's a valid answer. –  Jake Jul 11 '11 at 12:57
1  
@Jake: It's \scalebox{<h-scale>}[<v-scale>]{<text>}, so you would need to use \scalebox{2}[1]{FOO}. –  Martin Scharrer Jul 11 '11 at 13:34
    
@Martin: That approach would have the advantage that the vertical placement of the text remains unchanged. The label=center:<text> approach places the text right in the center of the node, whereas the node text would usually start a bit higher. –  Jake Jul 11 '11 at 13:39

2 Answers 2

up vote 1 down vote accepted

I would use the label=center:<text> option to place the node text, and leave the actual node text empty:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,fit}
\begin{document}
\begin{tikzpicture}
\node [draw] (ocr) at (0,0) {a};
\node [draw] (omr) at (2,1) {b};
\node[draw] (foo) [fit={(ocr) (omr)},xscale=0.5,yshift=2cm] {FOO};
\node[draw] (foo) [fit={(ocr) (omr)},xscale=0.5,label=center:FOO] {};
\end{tikzpicture}
\end{document}

xscale with unscaled text

share|improve this answer

As a workaround for single-line text you could scale the text back using the \scalebox{<h-scale>}[<v-scale>]{<text>} macro of graphics (which TikZ loads anyway). For a xscale=0.5 you use \scalebox{2}[1]{..} to scale to text by 2x in the X but keep it unscaled (1x) at the Y axis.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,fit}
\begin{document}
\begin{tikzpicture}
\node [draw] (ocr) at (0,0) {a};
\node [draw] (omr) at (2,1) {b};
\node[draw] (foo) [fit={(ocr) (omr)},xscale=0.5] {\scalebox{2}[1]{FOO}};
\end{tikzpicture}
\end{document}

Result

share|improve this answer

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.