1

I made a PSTricks figure to represent some IPSec behavior, but when \include-ing it, I have a scaling problem.

Here's what I produces. When compiling the separate file, everything is right, and all the frames have the same height.

MWE output

I try this answer, but it didn't work.

Here's my MWE :

\documentclass[pstricks, float]{standalone}
\usepackage{graphicx}
\usepackage[table, usenames, dvipsnames]{xcolor}
\usepackage{pstricks-add}
\usepackage[frenchb]{babel}
\usepackage[locale=FR, per-mode=symbol, abbreviations]{siunitx}

\begin{document}
\begin{pspicture}[showgrid=f](0, 0.75)(12.6, 5.2)

{\psset{framesep=10pt, cornersize=absolute,linecolor=black}
    {\psset{fillstyle=solid, fillcolor=lightgray}
        \rput[c](5.49,4.5){\rnode{ipsec1}{\psframebox[framesep=5pt]
            {\parbox{2.37cm}{\centering IPv4 Header\vphantom{y}\\
            next : \textcolor{Cerulean}{\bfseries TCP}}}}}
    }
    {\psset{fillstyle=solid, fillcolor=Cerulean}
        \rput[c](7.6,4.5){\rnode{tcp1}{\psframebox{TCP\vphantom{ay}}}}
        \rput[c](9.32,4.5){\rnode{payload1}{\psframebox{Payload}}}
    }
    \ncbar[angle=-90, armA=0.5cm, linecolor=Cerulean,offsetA=.5cm]{->}{ipsec1}{tcp1}



    {\psset{fillstyle=solid, fillcolor=lightgray}
        \rput[c](5.49,2){\rnode{ipsec2}{\psframebox[framesep=5pt]
            {\parbox{2.37cm}{\centering IPv4 Header\vphantom{y}\\
            next : \textcolor{BurntOrange}{\bfseries AH}}}}}
    }
    {\psset{fillstyle=solid, fillcolor=BurntOrange}
        \rput[c](7.96,2){\rnode{ah2}{\psframebox[framesep=5pt]
            {\parbox{1.85cm}{\centering AH Header\vphantom{y}\\
            next : \textcolor{Cerulean}{\bfseries TCP}}}}}
    }
    {\psset{fillstyle=solid, fillcolor=Cerulean}
        \rput[c](9.8,2){\rnode{tcp2}{\psframebox{{TCP\vphantom{ay}}}}
        \rput[c](11.52,2){\rnode{payload2}{\psframebox{Payload}}}
    }
    \ncbar[angle=-90, armA=0.5cm, linecolor=BurntOrange,offsetA=.5cm]{->}{ipsec2}{ah2}
    \ncbar[angle=-90, armA=0.5cm, linecolor=Cerulean,offsetA=.5cm]{->}{ah2}{tcp2}


}

\rput[c](2,4.5){IPv4 Datagram}
\rput[c](2,2){AH Datagram}
\end{pspicture}
\end{document}

BTW I don't think my code is optimal, so feel free to improve it !

3

Here is the first example as a simple tabular:

\documentclass{article}
\usepackage[table, dvipsnames]{xcolor}
\usepackage{pstricks-add}
\begin{document}

\begin{tabular}{@{} l | m{2cm} | l | l |}\cline{2-4}
IPv4 Datagram 
  & \cellcolor{black!15}IPv4 Header\strut\newline 
     next : \rnode{ipsec1}{\textcolor{Cerulean}{\bfseries TCP}}
  & \cellcolor{Cerulean}\rnode{tcp1}{TCP} \rule[-5mm]{0pt}{12mm}
  & \cellcolor{Cerulean}Payload\\\cline{2-4}
\end{tabular}   
\ncbar[angle=-90,nodesepA=8pt,nodesepB=14pt,armA=0.5cm,
       linecolor=Cerulean,arrowscale=2]{->}{ipsec1}{tcp1}

\end{document}

enter image description here

The second example can also be done with a tabular

and now the same without a tabular:

\documentclass[pstricks float]{standalone}
\usepackage[table, usenames, dvipsnames]{xcolor}
\usepackage{pstricks-add}
\begin{document}
\begin{pspicture}(0, 0.75)(12.6, 5.2)
\psset{fillstyle=solid,dimen=inner}
\psframe[fillcolor=lightgray](4.25,4)(6.75,5)
\rput(5.5,4.5){\rnode{ipsec1}{%
        \shortstack{IPv4 Header\\
                    next : \textcolor{Cerulean}{\bfseries TCP}}}}
\psframe[fillcolor=Cerulean](6.75,4)(7.75,5)
\rput(7.25,4.5){\rnode{tcp1}{TCP}}
\psframe[fillcolor=Cerulean](7.75,4)(9.25,5)
\rput(8.5,4.5){\rnode{payload1}{Payload}}
\ncbar[angle=-90,armA=0.6cm,linecolor=Cerulean,
       nodesepA=6pt,nodesepB=10pt,fillstyle=none]{->}{ipsec1}{tcp1}
\rput[c](2,4.5){IPv4 Datagram}
\end{pspicture}
\end{document}
  • Do you have a solution with the \pspicture I presented ? For my document I include them in, it's much easier... – EisenHeim May 15 '16 at 17:38
  • 1
    see edited answer – user2478 May 15 '16 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.