von mimu88 » Mi 11. Mär 2015, 20:35
Hallo.
In meinem Latex Dokument binde ich Quellcode mit
\begin{lstlisting}[caption=..., label={...}]
...
\end{lstlisting}
ein.
Ich brauche für den Quellcode die Zeilennummern. Der Quellcode sollte per Copy-Paste in den Interpreter kopiert werden können. Dies funktioniert alles soweit.
Allerdings habe ich im kopierten Text Zeilenumbrüche, wenn der Quellcode über die Seitenbreite hinaus geht. Die Zeilennummern stimmen aber. Wie kann ich verhindern, dass die Umbrüche mit kopiert werden?
Danke.
In der Präambel habe ich unter anderem:
\usepackage{accsupp}
\lstset{
language=Logo,
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
basicstyle=\footnotesize, % the size of the fonts that are used for the code
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
breaklines=true, % sets automatic line breaking
captionpos=b, % sets the caption-position to bottom
commentstyle=\color{mygreen}, % comment style
extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
keywordstyle=\bfseries\color{blue}, % keyword style
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
showstringspaces=false, % underline spaces within strings only
showtabs=false, % show tabs within strings adding particular underscores
stepnumber=2, % the step between two line-numbers. If it's 1, each line will be numbered
numbers=left,
numberstyle=\tiny\noncopynumber,
numbersep=8pt,
stringstyle=\color{mymauve}, % string literal style
tabsize=1, % sets default tabsize to 2 spaces
basicstyle=\ttfamily,
title=\lstname, % show the filename of files included with \lstinputlisting; also try caption instead of title
alsoletter={.},
upquote=true,
columns=fullflexible,
literate={*}{{\char42}}1
{-}{{\char45}}1,
morekeywords={...} % weitere keywords
}
\newcommand{\noncopynumber}[1]{
\BeginAccSupp{method=escape,ActualText={}}
#1
\EndAccSupp{}
}
Hallo.
In meinem Latex Dokument binde ich Quellcode mit
[tt]\begin{lstlisting}[caption=..., label={...}][/tt]
[tt]...[/tt]
[tt]\end{lstlisting}[/tt]
ein.
Ich brauche für den Quellcode die Zeilennummern. Der Quellcode sollte per Copy-Paste in den Interpreter kopiert werden können. Dies funktioniert alles soweit.
Allerdings habe ich im kopierten Text Zeilenumbrüche, wenn der Quellcode über die Seitenbreite hinaus geht. Die Zeilennummern stimmen aber. Wie kann ich verhindern, dass die Umbrüche mit kopiert werden?
Danke.
In der Präambel habe ich unter anderem:
[code]
\usepackage{accsupp}
\lstset{
language=Logo,
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
basicstyle=\footnotesize, % the size of the fonts that are used for the code
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
breaklines=true, % sets automatic line breaking
captionpos=b, % sets the caption-position to bottom
commentstyle=\color{mygreen}, % comment style
extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
keywordstyle=\bfseries\color{blue}, % keyword style
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
showstringspaces=false, % underline spaces within strings only
showtabs=false, % show tabs within strings adding particular underscores
stepnumber=2, % the step between two line-numbers. If it's 1, each line will be numbered
numbers=left,
numberstyle=\tiny\noncopynumber,
numbersep=8pt,
stringstyle=\color{mymauve}, % string literal style
tabsize=1, % sets default tabsize to 2 spaces
basicstyle=\ttfamily,
title=\lstname, % show the filename of files included with \lstinputlisting; also try caption instead of title
alsoletter={.},
upquote=true,
columns=fullflexible,
literate={*}{{\char42}}1
{-}{{\char45}}1,
morekeywords={...} % weitere keywords
}
\newcommand{\noncopynumber}[1]{
\BeginAccSupp{method=escape,ActualText={}}
#1
\EndAccSupp{}
}[/code]