<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% $Id: pst-exa.sty 239 2010-01-01 17:23:13Z herbert $
%% BEGIN pst-exa.tex
%%
%% Code and image side by side or on top of
%% each other with PSTricks.
%%
%% COPYRIGHT 2010 by Herbert Voss, hvoss tug.org.
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN
%% archives in directory macros/latex/base/lppl.txt.
%%
%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{graphicx}
\RequirePackage{listings}
\RequirePackage{pst-xkey}
\def\fileversion{0.01}
\def\filedate{2010/01/01}
%
\ProvidesPackage{pst-exa}[\filedate\ v\fileversion\ PSTricks example code (hv)]

\lstset{basicstyle=\ttfamily\footnotesize,numbers=left,numbersep=0.5pt,
    xleftmargin=1em,
    numberstyle=\tiny,breaklines,
    language=PSTricks}
\pst@addfams{pst-exa}
\define@key[psset]{pst-exa}{pos}[l]{%
  \ifx#1l\def\psk@exa@pos{0}
  \else
    \ifx#1r\def\psk@exa@pos{1}
    \else
      \ifx#1b\def\psk@exa@pos{2}
      \else  \def\psk@exa@pos{3}
  \fi\fi\fi}
\psset[pst-exa]{pos=l}
\define@key[psset]{pst-exa}{halign}[c]{\def\psk@exa@halign{#1}}
\psset[pst-exa]{halign=c}
\define@key[psset]{pst-exa}{valign}[c]{\def\psk@exa@valign{#1}}
\psset[pst-exa]{valign=c}
\define@key[psset]{pst-exa}{frame}[{}]{\def\psk@exa@frame{#1}}
\psset[pst-exa]{frame=}
\newlength\pst@exa@width
\define@key[psset]{pst-exa}{width}[0.5\linewidth]{\pssetlength\pst@exa@width{#1}}
\psset[pst-exa]{width=0.5\linewidth}
\newlength\pst@exa@sep
\define@key[psset]{pst-exa}{sep}[1em]{\pssetlength\pst@exa@sep{#1}}
\psset[pst-exa]{sep=1em}
%
\def\PSTfilename@i#1.#2.#3\@nil{\xdef\PSTfilename{#1.#2.tex}}%
%
\providecommand\IncludeGraphics[2][]{}
\renewcommand\IncludeGraphics[2][]{%
  \expandafter\PSTfilename@i#2\@nil%
  \includegraphics[#1]{#2}}
%
\newenvironment{PSTexample}[1][]
  {\par\noindent\psset{#1}%
   \begin{lrbox}{\pst@hbox}}
  {\end{lrbox}%
   \ifcase\psk@exa@pos 
     \minipage{\pst@exa@width}%
     \ifdim\wd\pst@hbox&lt;\linewidth\usebox\pst@hbox%
     \else\resizebox{\linewidth}{!}{\usebox\pst@hbox}\fi
     \endminipage\kern\pst@exa@sep%
     \pst@dimm=\linewidth%
     \advance\pst@dimm by -\pst@exa@width%
     \advance\pst@dimm by -\pst@exa@sep%
     \minipage{\pst@dimm}%
       \lstinputlisting[includerangemarker=false,firstnumber=1,
                    linerange=\\begin\{document\}-\\end\{document\}]{\PSTfilename}
    \endminipage%
  \or
     \pst@dimm=\linewidth%
     \advance\pst@dimm by -\pst@exa@width
     \advance\pst@dimm by -\pst@exa@sep
     \minipage{\pst@dimm}%
       \lstinputlisting[includerangemarker=false,firstnumber=1,
                    linerange=\\begin\{document\}-\\end\{document\}]{\PSTfilename}
    \endminipage\kern\pst@exa@sep%
    \minipage{\pst@exa@width}%
    \ifdim\wd\pst@hbox&lt;\linewidth\usebox\pst@hbox%
    \else\resizebox{\linewidth}{!}{\usebox\pst@hbox}\fi
    \endminipage
  \or
       \lstinputlisting[includerangemarker=false,firstnumber=1,
                    linerange=\\begin\{document\}-\\end\{document\}]{\PSTfilename}
    \par\vskip\pst@exa@sep%
    \usebox\pst@hbox\par
  \or
    \usebox\pst@hbox\par
    \vskip\pst@exa@sep%
       \lstinputlisting[includerangemarker=false,firstnumber=1,
                    linerange=\\begin\{document\}-\\end\{document\}]{\PSTfilename}\par
  \fi}
%
\endinput</pre></body></html>