spicing up your LaTeX
03:54 pm
The listings package for LaTeX allows you to prettyprint sourcecode that you include in your LaTeX document. It supports a stack of languages out of the box, but adding a new language is pretty straightforward. Here is an example of how you might add syntax highlighting for SPICE (it does not include the full set of SPICE keywords):

\usepackage{color}
\usepackage{listings}

...

\lstdefinelanguage{spice}{
        morekeywords={SUBCKT,MODEL,ENDS,END,PROBE,AC,NOISE,STEP,LIB,END},%
        sensitive=false,%
        morecomment=[f]*,%
        morestring=[m]",%
}
\def\lstbasicfont{\fontfamily{pcr}\selectfont}
\lstset{language=spice,
        keywordstyle=\bfseries,
        commentstyle=\color[gray]{0.6}\itshape,
        stringstyle=\color[gray]{0.5},
        basicstyle={\lstbasicfont\scriptsize},
        showstringspaces=false,
}

...

% some example SPICE
\begin{lstlisting}
*Analysis directives: 
.AC DEC 1 10k 10k
.NOISE V([N00258],[N00261]) V_V3 
.STEP LIN V_V4 0 15 0.25 
.PROBE
\end{lstlisting}
example output
(posted on Saturday September 29th, 2007 at 03:54 pm)

Livejournal

Navigation

Related Links

Syndication

RSS 2.0 Atom FOAF

Planetarium

Web Presence

Hacking Life   UCC   GNOME

Contact Me

License

Creative Commons License