von bloodworks » So 25. Dez 2011, 19:55
So ZB
\documentclass{scrreprt}
\usepackage{listings}
\usepackage[latin1]{inputenc}
\usepackage{xcolor}
\lstdefinestyle{mylax}{language= [latex]tex,captionpos=b,
frame= none,breaklines=true,
basicstyle= \small\ttfamily,
keywordstyle=\small\ttfamily\bfseries, commentstyle=\sffamily,
stringstyle=\ttfamily\itshape,
numbers=none, numberstyle=\tiny,aboveskip=5pt,
framesep=\baselineskip ,float={htbf},backgroundcolor=\color{black!05},
stepnumber=1,abovecaptionskip=5pt,numbersep=5pt,keywords={footheight,setlength,includegraphics,mathbb,mathcal }}
\lstdefinestyle{mymatl}{language=Matlab,
keywords={break,case,catch,continue,else,elseif,end,for,function,
global,if,otherwise,persistent,return,switch,try,while,ones,zeros},
captionpos=b, frame= none,breaklines=true, basicstyle= \small\ttfamily,
keywordstyle=\small\ttfamily\bfseries\color{red}, commentstyle=\sffamily,
stringstyle=\ttfamily\itshape, numbers=none, numberstyle=\tiny,aboveskip=5pt,
framesep=\baselineskip ,float={htbf},backgroundcolor=\color{black!05},
stepnumber=1,abovecaptionskip=5pt,numbersep=5pt}
\begin{document}
\begin{lstlisting}[caption=\protect\LaTeX, style=mylax]
\begin{document}
\end{lstlisting}
\begin{lstlisting}[caption=Matlab, style=mymatl]
>>for j=1:4,
>> v(j) = j;
>> end
>> v
v =
1 2 3 4
\end{lstlisting}
\end{document}
Für LATeX eigenet sich auch showexpl sehr gut
So ZB[code]
\documentclass{scrreprt}
\usepackage{listings}
\usepackage[latin1]{inputenc}
\usepackage{xcolor}
\lstdefinestyle{mylax}{language= [latex]tex,captionpos=b,
frame= none,breaklines=true,
basicstyle= \small\ttfamily,
keywordstyle=\small\ttfamily\bfseries, commentstyle=\sffamily,
stringstyle=\ttfamily\itshape,
numbers=none, numberstyle=\tiny,aboveskip=5pt,
framesep=\baselineskip ,float={htbf},backgroundcolor=\color{black!05},
stepnumber=1,abovecaptionskip=5pt,numbersep=5pt,keywords={footheight,setlength,includegraphics,mathbb,mathcal }}
\lstdefinestyle{mymatl}{language=Matlab,
keywords={break,case,catch,continue,else,elseif,end,for,function,
global,if,otherwise,persistent,return,switch,try,while,ones,zeros},
captionpos=b, frame= none,breaklines=true, basicstyle= \small\ttfamily,
keywordstyle=\small\ttfamily\bfseries\color{red}, commentstyle=\sffamily,
stringstyle=\ttfamily\itshape, numbers=none, numberstyle=\tiny,aboveskip=5pt,
framesep=\baselineskip ,float={htbf},backgroundcolor=\color{black!05},
stepnumber=1,abovecaptionskip=5pt,numbersep=5pt}
\begin{document}
\begin{lstlisting}[caption=\protect\LaTeX, style=mylax]
\begin{document}
\end{lstlisting}
\begin{lstlisting}[caption=Matlab, style=mymatl]
>>for j=1:4,
>> v(j) = j;
>> end
>> v
v =
1 2 3 4
\end{lstlisting}
\end{document}[/code]
Für LATeX eigenet sich auch showexpl sehr gut