Alexander Wollmann wrote:
>
> Hi everybody.
>
> As part of my exam-paper I wrote a C - program and now I have to write a
> documentation about this. So I need to include a lot of examples of the
> c-source-code to my paper. I thought the algorithm - float would do this, but I
> it doesn�t seem so. Can somebody tell me the way to get this to work? I need
> the source-code to look like in emacs, i.e typewriter font, and indents. For
> example this one:
choose the package listings and create a new command and a new counter
in the Latex-Preamble(Vorspann) like the following:
\newcommand{\lst}[2]{\vspace{0.5cm}\noindent
\refstepcounter{lst_counter}
\bf\ Listing
\arabic{chapter}-\arabic{lst_counter}\hspace{0.2cm}
\rm#2\lstinputlisting{#1}\indent}
\newcounter{lst_counter}[chapter]
at the beginning of your document you can set the values for the package
listings:
\lstset{language=Pascal,keywordstyle=\bfseries}
\lstset{basicstyle=\footnotesize,keywordstyle=\bfseries,nonkeywordstyle={},
blankstring=true,labelstyle=\tiny,labelstep=1,indent=2em,frame=lr}
I choosed the Pascal for my programming language but C is also
possible.
the new command lst has two parameters, the first one is the filename
for
the programm-code and the second for the title (opptional, may be
empty).
\lst{<file-name>}[the first programm}
the counting is same as the one for the sections. A new section returns
the counter "lst_counter".
I have two other new commands for only one line of programm-code and one
for typing code in regular text.
Herbert
--
[EMAIL PROTECTED]
http://www.canisius.de/