2

I´m trying doing some examples with pstricks, but I´m having problems, because only changing a cell of the psmatrix.... I have problems.

Could anyone help me with vertical spaces and and showing the final |nclines in the last images. ?

example file

3
  • 2
    Please don't link to an external file (unless you guarantee to preserve the link forever so as not to break the archives of this site) make a small complete document that shows the problem and paste it in to the question. Commented Apr 30, 2014 at 13:18
  • @DavidCarlisle ok, Can I attach files?
    – Mika Ike
    Commented Apr 30, 2014 at 13:24
  • No, you need to make the example small enough that it is reasonable for people to look at, then paste it in, using the {} button to format code sections. see meta.tex.stackexchange.com/a/3225/1090 Commented Apr 30, 2014 at 13:33

2 Answers 2

2

The \psframebox has internally no height. Use \vspace{..} instead. I also used \psscalebox instead of \resizebox. And, very important, do not use empty lines in a scale- or resizebox. I also used a tabular instead of the complicated \pspolygon. \TAB has three parameters: pezier coordinates, tab line, and text:

\documentclass[12pt,a4paper]{article}
\usepackage[table]{xcolor}
\def\TC{\textcolor{red}}
\usepackage{pst-node,graphicx,pst-blur}
\usepackage{array}
\newpsobject{psframegray}{psframebox}{fillcolor=lightgray,linestyle=none,shadow,blur} %del diagrama tabu
\def\TAB#1#2#3{\TABa#1;{#2}{#3}}% we need to exapand #1
\def\TABa#1;#2#3{%
  \psframegray{%
    \rule{0pt}{2\normalbaselineskip}% for the height    
    \ifx\relax#1\relax\else\psbezier[linewidth=0.06cm,linecolor=red]{<->}#1\fi
    \def\arraystretch{1.8}\tabcolsep=8pt
    ~\tabular{|c|c|c|c|}\hline #2  \\\hline
    \endtabular~}
    \rput[rb](0,-2\normalbaselineskip){#3}}

\begin{document}

\paragraph{Forma 1 de Generar Vecinos}
Intercambiando las tareas situadas en posiciones consecutivas.\\
Cada vecindario tendrá $(n-1)$ vecinos.

\begin{center}
\psscalebox{0.75}{%
\psset{framearc=0.2, shadowcolor=black!70, shadowangle=-90, unit=1.0cm}
\begin{psmatrix}[rowsep=1.5, colsep=2.5]% defines the distance between two frames
  & [name=Vecino1]\TAB{(0.5,0.7)(0.8,1)(1.1,1)(1.4,0.7)}%
                      {\TC{4} & \TC{3} & 2 & 1}%
                      {Vecino 1} \\
  & [name=Vecino2]\TAB{(1.3,0.7)(1.6,1)(1.9,1)(2.2,0.7)}%
                    {3 & \TC{2} & \TC{4} & 1 }%
                    {Vecino 2}\\  
 [name=SA]\TAB{}%%
              {3 & 4 & 2 & 1}%
              {Vecino 2}
 & [name=Vecino3]\TAB{(2.3,0.7)(2.6,1)(2.9,1)(3.2,0.7)}%
                    {3 & 4 & \TC{1} & \TC{2}}%
                    {Vecino 2}
\end{psmatrix}
\psset{linewidth=3pt,linecolor=red,arrows=->,nodesep=10pt,shortput=nab, npos = 0.4}
\ncline{SA}{Vecino1}\ncline{SA}{Vecino2}\ncline{Vecino3}{SA}%
}
\end{center}

\vspace{2\normalbaselineskip}
En cada vecindario con $n$ tareas, se obtienen $n-1$ vecinos, por lo que habrá que realizar otras tantas evlauaciones de la función objetivo en cada iteración.

\end{document}

enter image description here

And here comes your original code with correct vertical space.

\documentclass[12pt,a4paper]{article}
\usepackage{pst-node,graphicx,pst-blur}

\newpsobject{psframegray}{psframe}{fillcolor=lightgray,linestyle=none,shadow,blur} %del diagrama tabu
\begin{document}

\paragraph{Forma 1 de Generar Vecinos}
Intercambiando las tareas situadas en posiciones consecutivas.\\
Cada vecindario tendrá $(n-1)$ vecinos.

\vspace{2cm}
\psscalebox{0.75}{%
\psset{framearc=0.2, shadowcolor=black!70, shadowangle=-90, unit=1.0cm}
%\def\pscolhookii{\hskip 2cm}
\def\pscolhookii{\hskip 2cm}
%\def\pscolhookiii{\psset[pst-node]{mcol = l}}
\begin{psmatrix}[rowsep=2.5, colsep=2.9]% defines the distance between two frames
  %  \cnodeblue(0,0){0.15}{Current}
  &
  [name =Vecino1]
  \psframegray(.00,.00)(3.5,1.7)
    \pspolygon(0.5,0.2)(0.5,1.2)(2.3,1.2)(2.3,0.2)
    \pspolygon(1.1,0.2)(1.1,1.2)(2.9,1.2)(2.9,0.2)
    \pspolygon(1.7,0.2)(1.7,1.2)(2.9,1.2)(2.9,0.2)
    \rput[B](0.8,0.6){\textcolor{red}{4}}
    \rput[B](1.4,0.6){\textcolor{red}{3}}
    \rput[B](2.0,0.6){2}
    \rput[B](2.6,0.6){1}
    \psbezier[linewidth=0.06cm,linecolor=red]{<->}(0.8,1.3)(1.1,1.6)(1.1,1.6)(1.4,1.3)
    \rput[t](2.3,-.15){Vecino 1}
    \\%[0.88cm]
  &
  [name =Vecino2]
  \psframegray(.00,.00)(3.5,1.7)
    \pspolygon(0.5,0.2)(0.5,1.2)(2.3,1.2)(2.3,0.2)
    \pspolygon(1.1,0.2)(1.1,1.2)(2.9,1.2)(2.9,0.2)
    \pspolygon(1.7,0.2)(1.7,1.2)(2.9,1.2)(2.9,0.2)
    \rput[B](0.8,0.6){3}
    \rput[B](1.4,0.6){\textcolor{red}{2}}
    \rput[B](2.0,0.6){\textcolor{red}{4}}
    \rput[B](2.6,0.6){1}
    \psbezier[linewidth=0.06cm,linecolor=red]{<->}(1.4,1.3)(1.7,1.6)(1.7,1.6)(2.0,1.3)
    \rput[t](2.3,-.15){Vecino 2}
   \\
%
  [name =SA]
  \psframegray(.00,.00)(3.5,1.7)
    \pspolygon(0.5,0.2)(0.5,1.2)(2.3,1.2)(2.3,0.2)
    \pspolygon(1.1,0.2)(1.1,1.2)(2.9,1.2)(2.9,0.2)
    \pspolygon(1.7,0.2)(1.7,1.2)(2.9,1.2)(2.9,0.2)
    \rput[B](0.8,0.6){3}
    \rput[B](1.4,0.6){4}
    \rput[B](2.0,0.6){2}
    \rput[B](2.6,0.6){1}
    \rput[t](2.3,-.15){Solución Actual}
   &
   [name =Vecino3]
  \psframegray(.00,.00)(3.5,1.7)
    \pspolygon(0.5,0.2)(0.5,1.2)(2.3,1.2)(2.3,0.2)
    \pspolygon(1.1,0.2)(1.1,1.2)(2.9,1.2)(2.9,0.2)
    \pspolygon(1.7,0.2)(1.7,1.2)(2.9,1.2)(2.9,0.2)
    \rput[B](0.8,0.6){3}
    \rput[B](1.4,0.6){4}
    \rput[B](2.0,0.6){\textcolor{red}{1}}
    \rput[B](2.6,0.6){\textcolor{red}{2}}
    \psbezier[linewidth=0.06cm,linecolor=red]{<->}(2.0,1.3)(2.3,1.6)(2.3,1.6)(2.6,1.3)
    \rput[t](2.3,-.15){Vecino 3}
%
%%
\end{psmatrix}
%%% Links
\psset{linewidth=3pt, linecolor=red, arrows=->, nodesep=4pt,  linearc=0.25, angleB=180, shortput=nab, npos = 0.4}
\ncline[nodesepA = 2.0cm,nodesepB=0.5]{SA}{Vecino1}%
\ncline[nodesepA = 3.0cm,nodesepB=0.5]{SA}{Vecino2}%
\ncline[nodesepA = 4.0cm,nodesepB=0.5]{SA}{Vecino3}%
%\ncline[nodesepA = 4.8cm,nodesepB=0.5]{SA}{Vecino4}%
%\ncline[nodesepA = 4.8cm,nodesepB=0.5]{SA}{Vecino5}%
}

\vspace{1cm}
En cada vecindario con $n$ tareas, se obtienen $n-1$ vecinos, por lo que habrá que realizar otras tantas evlauaciones de la función objetivo en cada iteración.

\paragraph{Forma 2 de Generar Vecinos}
Analogamente a la primera forma, pero añadiendo el vecino en el que se intercambia la tarea de la última posición con la de la primera.\\
En este caso se obtienen $n$ vecinos, que requerirán $n$ evaluaciones.


\vspace{2cm}
\psscalebox{0.75}{%
\psset{framearc=0.2, shadowcolor=black!70, shadowangle=-90, unit=1.0cm}
\def\pscolhookii{\hskip 2cm}
%\def\pscolhookiii{\hskip 2cm}
%\def\pscolhookiii{\psset[pst-node]{mcol = l}}
\begin{psmatrix}[rowsep=1.9, colsep=2.9]% defines the distance between two frames
%
  %  \cnodeblue(0,0){0.15}{Current}
  &
  [name =Vecino1]
  \psframegray(.00,.00)(3.5,1.7)
    \pspolygon(0.5,0.2)(0.5,1.2)(2.3,1.2)(2.3,0.2)
    \pspolygon(1.1,0.2)(1.1,1.2)(2.9,1.2)(2.9,0.2)
    \pspolygon(1.7,0.2)(1.7,1.2)(2.9,1.2)(2.9,0.2)
    \rput[B](0.8,0.6){\textcolor{red}{4}}
    \rput[B](1.4,0.6){\textcolor{red}{3}}
    \rput[B](2.0,0.6){2}
    \rput[B](2.6,0.6){1}
    \psbezier[linewidth=0.06cm,linecolor=red]{<->}(0.8,1.3)(1.1,1.6)(1.1,1.6)(1.4,1.3)
    \rput[t](2.3,-.15){Vecino 1}
    \\%[0.88cm]
  &
  [name =Vecino2]
  \psframegray(.00,.00)(3.5,1.7)
    \pspolygon(0.5,0.2)(0.5,1.2)(2.3,1.2)(2.3,0.2)
    \pspolygon(1.1,0.2)(1.1,1.2)(2.9,1.2)(2.9,0.2)
    \pspolygon(1.7,0.2)(1.7,1.2)(2.9,1.2)(2.9,0.2)
    \rput[B](0.8,0.6){3}
    \rput[B](1.4,0.6){\textcolor{red}{2}}
    \rput[B](2.0,0.6){\textcolor{red}{4}}
    \rput[B](2.6,0.6){1}
    \psbezier[linewidth=0.06cm,linecolor=red]{<->}(1.4,1.3)(1.7,1.6)(1.7,1.6)(2.0,1.3)
    \rput[t](2.3,-.15){Vecino 2}
   \\
%
  [name =SA]
  \psframegray(.00,.00)(3.5,1.7)
    \pspolygon(0.5,0.2)(0.5,1.2)(2.3,1.2)(2.3,0.2)
    \pspolygon(1.1,0.2)(1.1,1.2)(2.9,1.2)(2.9,0.2)
    \pspolygon(1.7,0.2)(1.7,1.2)(2.9,1.2)(2.9,0.2)
    \rput[B](0.8,0.6){3}
    \rput[B](1.4,0.6){4}
    \rput[B](2.0,0.6){2}
    \rput[B](2.6,0.6){1}
    \rput[t](2.3,-.15){Solución Actual}
   &
   [name =Vecino3]
  \psframegray(.00,.00)(3.5,1.7)
    \pspolygon(0.5,0.2)(0.5,1.2)(2.3,1.2)(2.3,0.2)
    \pspolygon(1.1,0.2)(1.1,1.2)(2.9,1.2)(2.9,0.2)
    \pspolygon(1.7,0.2)(1.7,1.2)(2.9,1.2)(2.9,0.2)
    \rput[B](0.8,0.6){3}
    \rput[B](1.4,0.6){4}
    \rput[B](2.0,0.6){\textcolor{red}{1}}
    \rput[B](2.6,0.6){\textcolor{red}{2}}
    \psbezier[linewidth=0.06cm,linecolor=red]{<->}(2.0,1.3)(2.3,1.6)(2.3,1.6)(2.6,1.3)
    \rput[t](2.3,-.15){Vecino 3}\\
    &
   [name =Vecino4]
  \psframegray(.00,.00)(3.5,1.7)
    \pspolygon(0.5,0.2)(0.5,1.2)(2.3,1.2)(2.3,0.2)
    \pspolygon(1.1,0.2)(1.1,1.2)(2.9,1.2)(2.9,0.2)
    \pspolygon(1.7,0.2)(1.7,1.2)(2.9,1.2)(2.9,0.2)
    \rput[B](0.8,0.6){\textcolor{red}{1}}
    \rput[B](1.4,0.6){4}
    \rput[B](2.0,0.6){2}
    \rput[B](2.6,0.6){\textcolor{red}{3}}
    \psbezier[linewidth=0.06cm,linecolor=red]{<->}(0.8,1.3)(1.1,1.6)(2.3,1.6)(2.6,1.3)
    \rput[t](2.3,-.15){Vecino 4}
%
%%
\end{psmatrix}
%%% Links
\psset{linewidth=3pt, linecolor=red, arrows=->, nodesep=4pt,  linearc=0.25, angleB=180, shortput=nab, npos = 0.4}
\ncline[nodesepA = 2.0cm,nodesepB=0.5]{SA}{Vecino1}%
\ncline[nodesepA = 3.0cm,nodesepB=0.5]{SA}{Vecino2}%
\ncline[nodesepA = 4.0cm,nodesepB=0.5]{SA}{Vecino3}%
\ncline[nodesepA = 3.5cm,nodesepB=0.5]{SA}{Vecino4}%
%\ncline[nodesepA = 4.8cm,nodesepB=0.5]{SA}{Vecino5}%
}

\vspace{1cm}
En cada vecindario con $n$ tareas, se obtienen $n$ vecinos, por lo que habrá que realizar otras tantas evlauaciones de la función objetivo en cada iteración.\\
Esta forma inserta cierta dosis de diversificación pues el intercambio de la primera y última tarea puede suponer un cambio bastante considerable.\\

\end{document}
1

I modified a little your initial code (pstricks-add loads pst-node, \pstˆplot, pst-3d, pst-mathandmultido, so it's useless to load them again). I wrote two macros that simplify the main body:\mypsframegraydraws the grey frame, and the cells inside, defines one node per cell and manages the caption — that I right-align;\connect` … connects two nodes by a parabola. I think it's simpler than a Bézier curve of which you have to calculate the points. Finally I slighly modified some spacing parameters.

\documentclass[12pt,a4paper]{article}
\usepackage[top=2.5cm, left=3.5cm, bottom=2.5cm, right=2.5cm]{geometry}  % Margenes de la normativa TFG
\usepackage{lipsum}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
\usepackage{mathtools, amsfonts,amssymb,latexsym}
\usepackage{eurosym}
\usepackage{pstricks}
\usepackage{,pst-3dplot,pst-tree,pst-grad,pst-blur, pst-coil,pst-text,pst-eps,pst-fill,pstricks-add}
\newpsobject{psframegray}{psframe}{fillcolor=lightgray,linestyle=none,shadow,blur} %del diagrama tabu

\def\mypsframegray#1{%
\psframegray(0.0,0.0)(3.5,1.7)
    \pspolygon(0.5,0.2)(0.5,1.2)(2.3,1.2)(2.3,0.2)
    \pspolygon(1.1,0.2)(1.1,1.2)(2.9,1.2)(2.9,0.2)
    \pspolygon(1.7,0.2)(1.7,1.2)(2.9,1.2)(2.9,0.2)
    \pnodes{N}(0,0)(0.8, 0.6)(1.4, 0.6)(2.0, 0.6)(2.6, 0.6)
    \rput[t](3.5,-0.2){\llap{#1}}}%

\def\connect(#1)(#2){%
    \midAB(#1)(#2){S}
    \AplusB(S)(0,0.9){S}
    \AplusB(#1)(0,0.67){#1}
    \psparabola[linecolor = red, linewidth = 0.06cm]{<->}(#1)(S)}

\begin{document}


%\resizebox{12cm}{!}{    % if you want to resize

\psset{framearc=0.2, shadowcolor=black!70, shadowangle=-90, unit=1.0cm}
\def\pscolhookii{\hskip 3cm}
%\def\pscolhookiii{\hskip 2cm}
%\def\pscolhookiii{\psset[pst-node]{mcol = l}}

\begin{psmatrix}[rowsep=2.0, colsep=2.9cm, mnode = R]% defines the distance between two frames.
%
  %  \cnodeblue(0,0){0.15}{Current}
  &
  [name = VecinoUno1]
\mypsframegray{Vecino 1}
    \rput[B](N1){3}
    \rput[B](N2){\color{red}2}
    \rput[B](N3){\color{red}4}
    \rput[B](N4){1}
    \connect(N2)(N3)
    \\ %[0.88cm]
    &
  [name = VecinoDos2]
  \mypsframegray{Vecino 2}

    \rput[B](N1){3}
    \rput[B](N2){\color{red}1}
    \rput[B](N3){2}
    \rput[B](N4){\color{red}4}
    \connect(N2)(N4)
    \\%[0.88cm]
  {}[name =SAc]
  \mypsframegray{Solución Actual}
    \rput[B](0.8,0.6){3}
    \rput[B](1.4,0.6){4}
    \rput[B](2.0,0.6){2}
    \rput[B](2.6,0.6){1}
    \rput[t](2.3,-.15){}
   &
   [name =VecinoTres3]
  \mypsframegray{Vecino 3}
    \rput[B](N1){\color{red}1}
    \rput[B](N2){4}
    \rput[B](N3){2}
    \rput[B](N4){\color{red}3}
    \connect(N1)(N4)
    \\
    &
   [name =VecinoCuatro4]
  \mypsframegray{Vecino 4}
    \rput[B](N1){\color{red}2}
    \rput[B](N2){4}
    \rput[B](N3){\color{red}3}
    \rput[B](N4){1}
    \connect(N1)(N3)
%
%%
\end{psmatrix}
%%% Links
\psset{linewidth=3pt, linecolor=red, arrows=->, nodesep=4pt,  linearc=0.25, angleB=180, shortput=nab, npos = 0.4}
\ncline[nodesepA = 2.2cm,nodesepB=0.2]{SAc}{VecinoUno1}% 3.0  & 0.5
\ncline[nodesepA = 3.7cm,nodesepB=0.2]{SAc}{VecinoDos2}% 4.0
\ncline[nodesepA = 3.7cm,nodesepB=0.2]{SAc}{VecinoTres3}% 4.0
\ncline[nodesepA =2.0cm,nodesepB=0.2]{SAc}{VecinoCuatro4}% 4.8
%\ncline[nodesepA = 4.8cm,nodesepB=0.5]{SAc}{Vecino5}%
%}\\

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .