有人能帮忙解决 psmatrix 中文本上方的垂直空格问题吗?

有人能帮忙解决 psmatrix 中文本上方的垂直空格问题吗?

我正在尝试使用 pstricks 做一些示例,但遇到了问题,因为只改变了 psmatrix 的一个单元格......我遇到了问题。

有人能帮助我解决垂直空间问题并在最后的图像中显示最后的倾斜吗?

示例文件

答案1

内部没有\psframebox高度。请使用\vspace{..}代替。我还使用了\psscalebox代替\resizebox。并且,非常重要的一点是,不要在缩放或调整大小框中使用空行。我还使用了 表格 代替复杂的\pspolygon\TAB它有三个参数:佩齐尔坐标、制表符线和文本:

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

在此处输入图片描述

这是具有正确垂直空间的原始代码。

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

答案2

我稍微修改了你的初始代码(pstricks-add加载pst-node,,,pst-math multido \mypsframegray \connect`...通过抛物线连接两个节点。我认为它比必须计算点的贝塞尔曲线更简单。最后我稍微修改了一些间距参数\pstˆplotpst-3dand, so it's useless to load them again). I wrote two macros that simplify the main body:draws the grey frame, and the cells inside, defines one node per cell and manages the caption — that I right-align;

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

在此处输入图片描述

相关内容