Home > pstricks > Could anyone help with vertical spaces over text in psmatrix?

# Could anyone help with vertical spaces over text in psmatrix?

April 30Hits:0

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

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}
\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}{%
\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}



And here comes your original code with correct vertical space.

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

\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}{%
%\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}
\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}{%
\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}
\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}



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}

\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

\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}
\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}

`

## Related Articles

• ### Could anyone help with vertical spaces over text in psmatrix?April 30

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 -

• ### Reduce vertical space between text and table and remove table indentationFebruary 28

I want to reduce the vertical space between the first line text and the start of the table. I also want to remove the indent on the table, so that all three lines start at exactly the same vertical point. \documentclass[final,a4paper,notitlepage,10pt

• ### Remove vertical space between text and equations in column alignmentAugust 22

Is there a way to remove this large vertical space between my text and equations. I think this problem is a result of my aligning the equations into two columns.This is the code that I am using by the following CES aggregators: \begin{multicols}{2} \

• ### Vertical space between Text and figureNovember 4

If the code is like this: text text text text text.~\cite{sour}\begin{figure}[htbp] \centering \includegraphics[width=0.9\textwidth]{IMG/fig} \caption{Caption.} \label{fig:figlabel} \end{figure} No additional vertical space between the figure and the

• ### fncychap package - vertical gap/space between text and heading too large - how to reduce?March 13

The below example shows the table large gap between the top of the table of contents its section heading. How can this gap be reduced? \documentclass{book} \usepackage[Bjornstrup]{fncychap} \begin{document} \tableofcontents \chapter{This is an unnece

• ### Vertical space between headlines, tables, images and the following text too largeDecember 9

Is there a way to globally set a value (or minimum and maximum value) for the vertical space between, for instance, headlines, tables, images and the like and the following text. Right now I have the problem with my document that some of these vertic

• ### Vertical space between section header and text is too bigMarch 6

\documentclass[12pt,a4paper]{mwrep} \usepackage{polski} \usepackage[utf8]{inputenc} \usepackage{amsfonts} \usepackage[draft]{graphicx} \usepackage{amsmath} \usepackage[nodisplayskipstretch]{setspace} \setstretch{1.5} % Make all figure use 'ht' positi

• ### Adding vertical space without affecting the alignment of textSeptember 4

I would like to add some vertical space in my document without affecting the alignment and format of the sentences before the space. What exactly I do is : \cvsection{Education} \textbf{Some text} \years{2010-Expected December 2012} \\ \vspace{1.5mm}

How to adjust vertical space between headline and text box? I used [t] option but there is still a big space on the slide. \documentclass[compress,serif,xcolor=dvipsnames,xetex,t]{beamer} \usetheme{Madrid} \definecolor{Setcolor}{HTML}{6698FF} \usecol

• ### Vertical space between caption and main textJune 15

I am trying to adjust the vertical space between my captions and the main body of text below it. It is likely to be packages interfering with each other, but I am not sure which. Herbert suggested including these commands into my preamble, and I have

• ### Adjusting Text Vertical Space between lines in TikzDecember 3

I have this flowchart and the preamble is set to add a vertical space between lines and when I compiled this flowchart it follwed the preamble i guess. how can I adjust the vertical spaces of lines in my flow chart without affecting the other parts o

• ### Reduce vertical space between large table and text located above to fit in the same pageAugust 7

I need to fit one portion of text and threeparttable (fixed position in the manuscript) underneath, on a single page but I am not being able to. The table is large and would only fit in one page. One solution would be to reduce font size of the table

• ### Vertical spaces around display math July 28

I've heard that you should use $...$ for displayed equations instead of $$...$$, but why is that? I'd assumed that it's so that you can more easily tell which are starting and which are ending delimiters, but if I always use a syntax-highlighti

• ### In beamer class, how do I remove the additional vertical space before an itemize environment?September 21

On a beamer slide, I want to produce something like I use the following LaTeX code, which works well in LaTeX with the article class. \begin{minipage}[t]{1.4cm} Questions: \end{minipage}\nobreak \begin{minipage}[t]{9cm} \begin{itemize} \item 1st ques

• ### How to get rid of vertical space before and behind the listsNovember 18

I cannot get rid of the vertical space before and behind the lists. I have code like below: \begin{list}{-}{% \setlength{\itemsep}{0pt} \setlength{\parskip}{0pt} \setlength{\parsep}{0pt} } \item First item \item Second item \end{list} --------------S

• ### Vertical space before environmentsDecember 7

How can I control the vertical space before an environment, e.g., taublar or minipage. Here is an example that reproduces my problem \documentclass{article} \begin{document} \noindent TEXT-A\vspace{5pt}\\ TEXT-B\\TEXT-C \\[2em] \noindent TEXT-D\vspac

• ### An environment to change the vertical space around a formulaDecember 9

Specially in beamer presentations, I use a custom environment to change the vertical space around a formula. The code is: \newenvironment{shrinkeq}[1] { \bgroup \addtolength\abovedisplayshortskip{#1} \addtolength\abovedisplayskip{#1} \addtolength\bel

• ### How to make formulae take equal vertical space in the align environment?January 17

Consider the following code: \begin{align} f_1(x) &= \frac{15x}{3} \\ f_2(x) &= 3x + 5 \\ f_3(x) &= 4x + 13 \end{align} This produces three lines where the first line takes up more vertical space than the others. Is there any way to make all t

• ### Vertical space in listsFebruary 9

What is the best way to globally change the amount of vertical space between items in list environments? --------------Solutions------------- The easiest way to do this is to use the enumitem package. \documentclass{article} \usepackage{lipsum} % for