%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% !TEX TS-program = pdflatex
%
% Default Typesetting program is "pdflatex"
%
% File: p4tex.tex
%
% P4 PDL Listing Template
% Produce first class P4 code listings from P4 source files.
% Requires little or no editing of the original source file.
% Math statements will need '$' brackets to indicate in-line math.
% The dollar signs will be stripped off when the listing is
% typeset.
%
% Uses the 'listings' package
% See C:\Program Files\MiKTeX 2.9\doc\latex\listings\listings.pdf
%
% Curtis G. Flippin
% Flippin Engineering
% 23 April 2014
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Not using the usual Latin Modern font. Going with supplied fonts.
% Font family, shape, or series is set per P4 custom and code
% circumstances.
%
\documentclass{article}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use listings package with options:
%    o final vs draft
%
\usepackage[final]{listings}
%
% Use amsmath package if code contains a lot of complex math.
% Some options may not play nicely with listings package.
% Most in-line math can be handled by [mathescape] option in
% environment {lstlisting}.
%
\usepackage{amsmath}
\usepackage{amssymb}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Managing Page dimensions
%
\usepackage{geometry}
%
% Set the letter paper margins to 1.0 inches all around.
% Set headheight to 14 pts to allow for various page styles (fancy).
% See fancyhdr package.
% Default layout is portrait. Refer to geometry.pdf
%
\geometry{letterpaper, margin=1.0in, head=14pt}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\begin{document}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define the P4 language:
%    o keywords to be highlighted using keywordstyle;
%    o keywords are not case sensitive although P4 does
%      not use upper case for keywords by convention;
%    o technical side comments use a slanted bold font
%      typeface. This to draw attention to these notes;
%    o comments are Roman with an upright shape. This makes
%      them compact yet very readable. Especially important
%      when comments are lengthy.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\lstdefinelanguage{P4}
{morekeywords={begin,end,function,procedure,call,return,
if,elseif,else,endif,case,when,other,endcase,while,until,
repeat,do,define,as},
sensitive=false,
morecomment=[s][\slshape\bfseries]{??}{??},
morecomment=[s][\rmfamily\upshape]{(*}{*)},
morestring=[b]",
morestring=[b]',
}
%    Select the P4 language
\lstset{language=P4}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Your text editor should be set up as follows:
%    o 72 character line;
%    o wrap (if used) maintains indent;
%    o uses spaces for tabs;
%    o tab size = 3;
%    o indent = 3
%    o set fixed tab stops at column numbers:
%      4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43,
%      46, 49, 52, 55, 61, 67
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Typeset the source file. Always use the mathescape option and
% bracket P4 math statements within dollar ($) signs.
%%% Filespec argument must be full path or the file may be placed
%%% in the same directory as this file (p4tex.tex).
%%% The proper file extension for P4 documents is .p4t which means
%%% P4 Technical. P4 is a Procedural Design Language (PDL).
%
\lstinputlisting[mathescape]{temp.p4t}
%
\end{document}