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 need to wrap the text around my tikz picture. But as you can see, scaling the picture give me problems about the position of the shaded axis between "pompa" and "turbina". How can i fix this problem?

\documentclass[a4paper,12pt]{report} \usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} \usepackage[italian]{babel}

\usepackage{wrapfig} \usepackage{bm}

\usepackage{tikz}
 \usetikzlibrary{positioning,intersections,shapes.geometric,decorations.pathmorphing,decorations.pathreplacing,decorations.shapes,decorations.markings,patterns,calc,fit,arrows,backgrounds}

 \begin{document}

 \begin{wrapfigure}{r}{0.5\textwidth} \vspace{-1cm}

 \centering \begin{tikzpicture}[>=latex',auto,inner sep=2mm,node
 distance=2cm and 3cm,transform canvas={scale=0.85}]

 %setting styles

 \tikzset{box1/.style={draw,minimum width=2cm,rectangle,thick}}
 \tikzset{deco/.style={decoration={markings, mark=at position #1 with
 {\arrow{>} }},postaction={decorate}}}
 \tikzset{turb/.style={draw,trapezium,shape border rotate=90,inner
 sep=1pt,minimum width=2.5cm,trapezium stretches=true,trapezium
 angle=80,on grid,below right= of evaporatore}}                       
 \tikzset{every pin edge/.style={<-,shorten
 >=-0.2cm,decorate,decoration={bent,amplitude=-2,aspect=0.3}}}

 %define nodes and labels 
 \node[box1] (setA)   [label=right:$T_A$]     
 {\textit{SET A}}; \node[box1,below=1cm of setA] (evaporatore)         
 {\textit{Evaporatore}}; \node[turb,fill=white] (turbina)              
 {\textit{Turbina}}; \node[box1,right=1cm of turbina] (sem)            
 {\textit{SEM}}; \node[box1,on grid,below left=of turbina]
 (condensatore)                               {\textit{Condensatore}};
 \node[draw,circle,fill=white,on grid,below left= of evaporatore,inner
 sep=1mm] (pompa) {\textit{Pompa}}; \node[box1] (setB)  [below=1 cm of
 condensatore] [label=right:$T_B$]                   {\textit{SET B}};

 %the "IMT" dashed box and label 
 \node (imt) [draw,dashed,inner
 sep=3pt,fit = (evaporatore) (turbina) (condensatore)(pompa),pin={[pin
 distance=10mm] 30:\textit{IMT}}]  {};


 %drawing connections between components 
 \begin{scope}[>=triangle 60] 
 \draw [deco=0.6]  (evaporatore)                -| node[pos=0.6]{2}
 (turbina.top right corner);  \draw [deco=0.6]  (turbina.bottom left
 corner) |- node[above=1mm,pos=0.71]{3} (condensatore);  \draw
 [deco=0.4]  (condensatore)               -|
 node[above=1mm,pos=0.31]{4} (pompa);  \draw [deco=0.6]  (pompa)       
 |- node[below=1mm,pos=0.63]{1} (evaporatore); \end{scope}

 %drawing the arrows

 \begin{scope}[>=stealth', shorten >=-0.0cm,shorten <=-0.0cm,->] 
 \path[thick] (setA)         edge node[] {$\bm{q_A}$} (evaporatore)
                   (turbina)      edge node[] {$\bm{l}$}   (sem)
                   (condensatore) edge node[] {$\bm{q_B}$} (setB); \end{scope}

 % drawing the shaded axis between "pompa" and "turbina"

 \begin{scope}[on background layer] \draw[shading=axis]
 ($(pompa.center)+(0,-3pt)$) rectangle ($(turbina.center)+(0,3pt)$);
 \end{scope} \end{tikzpicture}

 \vspace{6cm} \end{wrapfigure}

 Il funzionamento di tutti gli impianti motori termici si basa sul
 ciclo diretto di Carnot: chiaramente l'impianto motore dovrà essere
 formato da più macchine, o componenti, in grado di realizzare tali
 trasformazioni sul fluido di lavoro. Tipicamente gli scambi di energia
 termica \textit{1-2} e \textit{3-4}  si ottengono mediante scambiatori
 di calore ; l’espansione \textit{2-3} è ottenuta mediante una turbina
 (a gas o a vapore); la compressione \textit{4-1} è ottenuta mediante
 un compressore (se il fluido di lavoro si trova in fase gassosa) o una
 pompa (liquido).

 In figura riportiamo lo schema di funzionamento di un impianto motore
 termico con turbina a vapore.

 \end{document}

This is the original picture:

\documentclass{article}  \usepackage{tikz}
 \usetikzlibrary{positioning,
                intersections,
                shapes.geometric,
                decorations.pathmorphing,
                decorations.pathreplacing,
                decorations.shapes,
                decorations.markings,
                patterns,
                calc,
                fit,
                arrows,
                backgrounds}
                 \usepackage{bm}

 \begin{document}

 \begin{tikzpicture}[>=latex',auto,inner sep=2mm,node distance=2cm and
 3cm]

 %setting styles

 \tikzset{box1/.style={draw,minimum width=2cm,rectangle,thick}}
 \tikzset{deco/.style={decoration={markings, mark=at position #1 with
 {\arrow{>} }},postaction={decorate}}}
 \tikzset{turb/.style={draw,trapezium,shape border rotate=90,inner
 sep=1pt,minimum width=2.5cm,trapezium stretches=true,trapezium
 angle=80,on grid,below right= of evaporatore}}                       
 \tikzset{every pin edge/.style={<-,shorten
 >=-0.2cm,decorate,decoration={bent,amplitude=-2,aspect=0.3}}}

 %define nodes and labels 
 \node[box1] (setA)   [label=right:$T_A$]     
 {\textit{SET A}}; \node[box1,below=1cm of setA] (evaporatore)         
 {\textit{Evaporatore}}; \node[turb,fill=white] (turbina)              
 {\textit{Turbina}}; \node[box1,right=1cm of turbina] (sem)            
 {\textit{SEM}}; \node[box1,on grid,below left=of turbina]
 (condensatore)                               {\textit{Condensatore}};
 \node[draw,circle,fill=white,on grid,below left= of evaporatore,inner
 sep=1mm] (pompa) {\textit{Pompa}}; \node[box1] (setB)  [below=1 cm of
 condensatore] [label=right:$T_B$]                   {\textit{SET B}};

 %the "IMT" dashed box and label 
 \node (imt) [draw,dashed,inner
 sep=3pt,fit = (evaporatore) (turbina) (condensatore)(pompa),pin={[pin
 distance=10mm] 30:\textit{IMT}}]  {};


 %drawing connections between components 
\begin{scope}[>=triangle 60] 
 \draw [deco=0.6]  (evaporatore)                -| node[pos=0.6]{2}
 (turbina.top right corner);  \draw [deco=0.6]  (turbina.bottom left
 corner) |- node[above=1mm,pos=0.71]{3} (condensatore);  \draw
 [deco=0.4]  (condensatore)               -|
 node[above=1mm,pos=0.31]{4} (pompa);  \draw [deco=0.6]  (pompa)       
 |- node[below=1mm,pos=0.63]{1} (evaporatore); \end{scope}

 %drawing the arrows

 \begin{scope}[>=stealth', shorten >=-0.0cm,shorten <=-0.0cm,->] 
 \path[thick] (setA)         edge node[] {$\bm{q_A}$} (evaporatore)
                   (turbina)      edge node[] {$\bm{l}$}   (sem)
                   (condensatore) edge node[] {$\bm{q_B}$} (setB); \end{scope}

 % drawing the shaded axis between "pompa" and "turbina"

 \begin{scope}[on background layer] \draw[shading=axis]
 ($(pompa.center)+(0,-3pt)$) rectangle ($(turbina.center)+(0,3pt)$);
 \end{scope}

 \end{tikzpicture} 
\end{document}
share|improve this question
2  
We're getting there: Code should be formatted using the {} key (or indenting each line by four spaces), not using the " key -- that's for quotes. Also, examples should be minimal: Don't just dump your whole code in the question, but remove all the bits that aren't directly related to the problem. In this case, you should make up a small example that demonstrates the problem. –  Jake May 2 '12 at 12:28
    
@Edo: Wow, that's very kind of you to clean the code formatting. I tried, but it inserted lots of empty lines and weird line breaks, so I gave up. Really, that's something you can leave the poster do correct themselves. –  Jake May 2 '12 at 12:39
    
You can scale everything using \scalebox{<factor>}{<content>} or \resizebox{<width>}{<height>}{<content>} from the graphicx package (already loaded by tikz). Try \resizebox{<your width>}{!}{<your tikz picture>}. Having the tikzpicture in an extra file would be better IMHO. Have a look at standalone which also gives you \includestandalone[width=<width>]{<source file>} (also height and scale etc.) –  Martin Scharrer May 2 '12 at 12:42
2  
@Jake: Well let's say that not well-indented or well-formatted code hurts me way more than editing :) –  Edo May 2 '12 at 12:45
    
@Edo Indeed, thanks for the effort. I've fixed a few places where commands shifted into commented lines (in case you wonder about the reason of the edit). –  percusse May 2 '12 at 12:48
show 1 more comment

1 Answer

Little job or handiwork, I don't know how to design my work.

Firstly I try to give a solution. Your problem comes from the use of transform canvas={scale=0.8} with [on background layer]. If you don't use layer then you need to place the shaded axis before the turbina and the pompa. I remove some options of these objects like draw and to get the exact size, I used \hphantom to avoid to write the texts.

Then, at the end of the picture, I draw the pompa and the turbina above the shaded axis.

Now about the general method. Before to code a complex figure like this, you need to know what you want to do with : scale or not scale is the question. If you want to scale the figure, you need to use carefully some tools like node, positioning. You need to write correctly the dimensions (absolute with units or without units). In this case, you can use nodes but before I think it was better to define coordinates to place pompa, turbina, evaporatore etc. It will be more easy to scale the objects. About other solutions, the problem if you use resizebox or something like that, it's the size of the fonts, the width of the lines etc. A good thing is to avoid scaling (idea of T. Tantau and to draw at the good size), personally I prefer to use the good tools for an easy scaling.

\documentclass[a4paper,12pt]{report} 
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} 
\usepackage[italian]{babel}
\usepackage{wrapfig} 
\usepackage{bm}
\usepackage{tikz}
 \usetikzlibrary{positioning,intersections,shapes.geometric,decorations.pathmorphing,decorations.pathreplacing,decorations.shapes,decorations.markings,patterns,calc,fit,arrows,backgrounds}

 \begin{document}

\begin{wrapfigure}{r}{0.5\textwidth} \vspace{-1cm}
 \centering 

 \begin{tikzpicture}[>=latex',auto,
                     inner sep=2mm,
                     node distance=2cm and 3cm,
                     transform canvas={scale=0.8}]

 %setting styles

 \tikzset{box1/.style={draw,minimum width=2cm,rectangle,thick}}
 \tikzset{deco/.style={decoration={markings, mark=at position #1 with
 {\arrow{>} }},postaction={decorate}}}
 \tikzset{turb/.style={draw,trapezium,shape border rotate=90,
                       inner sep=1pt,minimum width=2.5cm,
                       trapezium stretches=true,
                       trapezium angle=80,on grid,
                       below right= of evaporatore}}                       
 \tikzset{every pin edge/.style={<-,shorten >=-0.2cm,
                        decorate,
                        decoration={bent,amplitude=-2,aspect=0.3}}}

 %define nodes and labels 
 \node[box1] (setA)   [label=right:$T_A$]     {\textit{SET A}}; 
 \node[box1,below=1cm of setA] (evaporatore)  {\textit{Evaporatore}}; 
 \node[turb,fill=white] (turbina)             {\hphantom{\textit{Turbina}}}; 
 \node[box1,right=1cm of turbina] (sem)       {\textit{SEM}}; 
 \node[box1,on grid,below left=of turbina] (condensatore)  {\textit{Condensatore}};
 \node[circle,on grid, below left= of evaporatore,inner sep=1mm] (pompa) {\hphantom{\textit{Pompa}}}; 
 \node[box1] (setB)  [below=1 cm of condensatore] [label=right:$T_B$]  {\textit{SET B}};

 %the "IMT" dashed box and label 
 \node (imt) [draw,dashed,inner sep=3pt,
             fit = (evaporatore) (turbina) (condensatore)(pompa),
             pin={[pin distance=10mm] 30:\textit{IMT}}]  {};

 %drawing connections between components 
 \begin{scope}[>=triangle 60] 
     \draw [deco=0.6] (evaporatore)  -| node[pos=0.6]{2} (turbina.top right corner);  
     \draw [deco=0.6] (turbina.bottom left corner) |- node[above=1mm,pos=0.71]{3} (condensatore);  
     \draw[deco=0.4]  (condensatore)    -| node[above=1mm,pos=0.31]{4} (pompa);  
     \draw [deco=0.6] (pompa)  |- node[below=1mm,pos=0.63]{1} (evaporatore); 
 \end{scope}

 %drawing the arrows

 \begin{scope}[>=stealth', shorten >=-0.0cm,shorten <=-0.0cm,->] 
   \path[thick] (setA)         edge node[] {$\bm{q_A}$} (evaporatore)
                (turbina)      edge node[] {$\bm{l}$}   (sem)
                (condensatore) edge node[] {$\bm{q_B}$} (setB); 
 \end{scope}

 % drawing the shaded axis between "pompa" and "turbina"

 \begin{scope}%[on background layer] 
   \draw[shading=axis] ($(pompa.east)+(0,-3pt)$) rectangle ($(turbina.west)+(0,3pt)$);
 \end{scope} 

\node[turb,fill=white] (turbina)    {\textit{Turbina}}; 
 \node[draw,circle,
       fill=white,on grid,
       below left= of evaporatore,
       inner sep=1mm] (pompa) {\textit{Pompa}};  
\end{tikzpicture}

 \vspace{6cm} \end{wrapfigure}

 Il funzionamento di tutti gli impianti motori termici si basa sul
 ciclo diretto di Carnot: chiaramente l'impianto motore dovrà essere
 formato da più macchine, o componenti, in grado di realizzare tali
 trasformazioni sul fluido di lavoro. Tipicamente gli scambi di energia
 termica \textit{1-2} e \textit{3-4}  si ottengono mediante scambiatori
 di calore ; l’espansione \textit{2-3} è ottenuta mediante una turbina
 (a gas o a vapore); la compressione \textit{4-1} è ottenuta mediante
 un compressore (se il fluido di lavoro si trova in fase gassosa) o una
 pompa (liquido).

 In figura riportiamo lo schema di funzionamento di un impianto motore
 termico con turbina a vapore.

 \end{document}

enter image description here

share|improve this answer
add comment

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.