
순서도를 그리려고 하는데 몇 가지 패키지를 살펴봤습니다. 좀 더 익숙해서 pstricks
선택했고, 예시들을 확인하면서 환경과 함께 그려보려고 합니다 psmatrix
.
선생님은 "초기화"가 평행사변형으로 작성되어야 한다고 말씀하셨는데, 제가 그것을 순서도에 그리려고 했을 때 평행사변형에 어떤 구문을 사용해야 할지 전혀 몰랐습니다!
이에 대한 특정 명령이 있습니까?
\psdiabox
평행사변형을 얻으려면 특정 각도를 사용해야 합니까 ? 그렇다면 각도를 어떻게 정의해야 합니까?
다음은 직사각형 대신 평행사변형으로 빨간색 상자("초기화")를 갖고 싶은 곳에 그리는 예입니다.
\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{pst-blur}
\definecolor{Pink}{rgb}{1.,0.75,0.8}
\pagestyle{empty}
\begin{document}
\vspace{0.5cm}
\small
\psset{shadowcolor=black!70,blur=true}
\begin{psmatrix}[rowsep=0.4,colsep=0.5]
\psovalbox{Begin} \\
\psframebox[,fillstyle=solid,fillcolor=red]{Initialisations} \\
\psdiabox{Special} &
\psframebox[shadow=true]{Call to SP1} & \psframebox[shadow=true]{Call to SP2} \\
\psframebox{Action 1} \\
~\\
\psframebox{Action 2} \\
\psovalbox{End}
% Links
\ncline{->}{1,1}{2,1}
\ncline{->}{2,1}{3,1}
\ncline{->}{3,1}{4,1}<{\textcolor{red}{No}}
\ncline{->}{4,1}{6,1}
\ncline{->}{6,1}{7,1}
\ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}
\ncline{->}{3,2}{3,3}
\ncbar[angleA=-90,armB=0,nodesepB=0.25]{->}{3,3}{4,1}
\end{document}
답변1
\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node,pst-3d}
\usepackage{pst-blur}
\definecolor{Pink}{rgb}{1.,0.75,0.8}
\makeatletter
\newsavebox\TBox
\newcommand\psParaBox[2][]{{
\psset{framesep=5pt,gangle=60,#1}%
\sbox\TBox{\psTilt{\psk@gangle}{\psframebox{\phantom{ #2}}}}%
\usebox\TBox%
\rput(-0.5\wd\TBox,\dimexpr 0.5\ht\TBox-0.5ex\relax){ #2}}}
\makeatother
\pagestyle{empty}
\begin{document}
\psset{shadowcolor=black!70,blur}
\begin{psmatrix}[rowsep=0.4,colsep=0.5]
\psovalbox{Begin} \\
\psParaBox[fillstyle=solid,fillcolor=red!40]{Initialisations} \\
\psdiabox{Special} &
\psframebox[shadow=true]{Call to SP1} & \psframebox[shadow=true]{Call to SP2} \\
\psframebox{Action 1} \\
~\\
\psframebox{Action 2} \\
\psovalbox{End}
% Links
\ncline{->}{1,1}{2,1}
\ncline{->}{2,1}{3,1}
\ncline{->}{3,1}{4,1}<{\textcolor{red}{No}}
\ncline{->}{4,1}{6,1}
\ncline{->}{6,1}{7,1}
\ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}
\ncline{->}{3,2}{3,3}
\ncbar[angleA=-90,armB=0,nodesepB=0.25]{->}{3,3}{4,1}
\end{psmatrix}
\end{document}
답변2
다음은 \psparallelogram[<options>]{<stuff>}
동일한 방식으로 작동 \psdiabox
하고 \psframebox
작동하는 것을 정의합니다.
\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{pst-blur}
\definecolor{Pink}{rgb}{1.,0.75,0.8}
% ================================
% Source: http://tug.org/pipermail/pstricks/2009/006766.html
\makeatletter
\newdimen\psparallelogramsep
\def\psset@parallelogramsep#1{\pssetlength\psparallelogramsep{#1}}
\psset@parallelogramsep{3mm}
\def\psparallelogrambox{\pst@object{psparallelogrambox}}
\def\psparallelogrambox@i{\pst@makebox\psparallelogrambox@ii}
\def\psparallelogrambox@ii{%
\begingroup
\pst@useboxpar
\pst@dima=\pslinewidth
\advance\pst@dima by \psframesep
\pst@dimc=\wd\pst@hbox\advance\pst@dimc by \pst@dima
\pst@dimb=\dp\pst@hbox\advance\pst@dimb by \pst@dima
\pst@dimd=\ht\pst@hbox\advance\pst@dimd by \pst@dima
\setbox\pst@hbox=\hbox{%
\ifpsboxsep\kern\pst@dima\fi
\begin@ClosedObj
\addto@pscode{%
\psk@cornersize
\pst@number\pst@dima neg
\pst@number\pst@dimb neg
\pst@number\pst@dimc
\pst@number\pst@dimd .5
\pst@number\psparallelogramsep
\tx@Parallelogram}%
\def\pst@linetype{2}%
\showpointsfalse
\end@ClosedObj
\box\pst@hbox
\ifpsboxsep\kern\pst@dima\fi%
}%
\ifpsboxsep\dp\pst@hbox=\pst@dimb\ht\pst@hbox=\pst@dimd\fi
\leavevmode\box\pst@hbox
\endgroup%
}
% From the Frame and Rect PostScript macros
\pst@def{Parallelogram}<{%
/ParallelogramA {
x1 pgs sub y1 moveto
x1 y2 lineto
x2 pgs add y2 lineto
x2 y1 lineto
x1 pgs sub y1 lineto
closepath} def
%
/pgs ED
CLW mul
/a ED
3 -1 roll
2 copy gt { exch } if
a sub
/y2 ED
a add
/y1 ED
2 copy gt { exch } if
a sub
/x2 ED
a add
/x1 ED
1 index 0 eq {pop pop ParallelogramA } { OvalFrame } ifelse}>
\makeatother
\def\pspbox[#1]#2{\makebox[#1]{\psparallelogrambox{#2}}}
% ================================
\pagestyle{empty}
\begin{document}
\vspace{0.5cm}
\small
\psset{shadowcolor=black!70,blur=true}
\begin{psmatrix}[rowsep=0.4,colsep=0.5]
\psovalbox{Begin} \\
%\psframebox[fillstyle=solid,fillcolor=red]{Initialisations} \\
\psparallelogrambox[fillstyle=solid,fillcolor=red]{Initialisations} \\
\psdiabox{Special} &
\psframebox[shadow=true]{Call to SP1} & \psframebox[shadow=true]{Call to SP2} \\
\psframebox{Action 1} \\
~\\
\psframebox{Action 2} \\
\psovalbox{End}
% Links
\ncline{->}{1,1}{2,1}
\ncline{->}{2,1}{3,1}
\ncline{->}{3,1}{4,1}<{\textcolor{red}{No}}
\ncline{->}{4,1}{6,1}
\ncline{->}{6,1}{7,1}
\ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}
\ncline{->}{3,2}{3,3}
\ncbar[angleA=-90,armB=0,nodesepB=0.25]{->}{3,3}{4,1}
\end{psmatrix}
\end{document}
평행사변형의 소스는 PStrics 메일링 항목에서 가져왔습니다.나무의 평행사변형.