Problem mit Packet listings

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: Problem mit Packet listings

von Tanata » Di 29. Jun 2010, 12:08

Danke Koma,

werde es konsultieren!

Tanata.

Problem mit Packet listings

von Tanata » Di 29. Jun 2010, 12:06

Leider funktioniert es nur in diesem Minimalbeispiel. In meiner echten LaTeX Datei, die eine Dokumentation einer Access-Datenbank samt kommentiertem VBA-Code enthält, funktioniert es nicht. Es gibt eine Fehlermeldung. Das ist aber nicht so einfach und ist entweder ein Bug oder ein Kompatibilitätsproblem. Ich hab euch mal den Text aus der listings Dokumentation, der hier nun zum greifen kommt, wie ich meine.
National characters If you type in such characters directly as characters of
codes 128–255 and use them also in listings, let the package know it—or you’ll
get really funny results. extendedchars=true allows and extendedchars=false
prohibits listings from handling extended characters in listings. If you use them,
you should load fontenc, inputenc and/or any other package which defines the
characters.

! I have problems using inputenc together with listings. This could be a compatibility
problem. Make a bug report as described in section 6 Troubleshooting.
The extended characters don’t cover Arabic, Chinese, Hebrew, Japanese, and so
on—specifically, any encoding which uses multiple bytes per character.
Thus, if you use the a package that supports multibyte characters, such as
the CJK or ucs packages for Chinese and UTF-8 characters, you must avoid letting
listings process the extended characters. It is generally best to also specify
13
extendedchars=false to avoid having listings get entangled in the other package’s
extended-character treatment.

If you do have a listing contained within a CJK environment, and want to
have CJK characters inside the listing, you can place them within a comment
that escapes to LATEX– see section 4.14 for how to do that. (If the listing is not
inside a CJK environment, you can simply put a small CJK environment within
the escaped-to-LATEXportion of the comment.)

Similarly, if you are using UTF-8 extended characters in a listing, they must
be placed within an escape to LATEX.
Also, section 7 has a few details on how to work with extended characters in
the context of .
Es gibt Hoffnung, aber ist wird ein zähes Erlesen von neuer Information sein.

Gruß, Tanata

von KOMA » Di 29. Jun 2010, 11:55

Siehe zum Stichwort utf8 und listings auch listingsutf8.

von Xenara » Di 29. Jun 2010, 11:35

Ah, ok. Ich arbeite auf WinXP standardmässig mit latin1, daher habe ich es umgestellt, und nachdem der Fehler mit den extendedchars=true behoben war, habe ich nicht mehr weiter nachgeforscht.
Gut, dass du eine Lösung gefunden hast.

Problem mit Packet listings

von Tanata » Di 29. Jun 2010, 11:24

Hallo Xenara,

das liegt in Wirklichkeit an dem Encoding utf8, ich arbeite mit LaTex unter OpenSuse. Mit latin1 taucht das Problem nicht auf, nur mit utf8. Wenn du mehr wissen willst, in der Dokumentation zum listings Packet steht da mehr zu, was ich aber nicht wirklich verstehe.

Und was ein "escape to LateX" ist weiß ich auch nicht, doch das soll
texcl=true
zustande bringen. Es geht im Minimalbeispiel. Jetzt schaue ich, ob es in meiner echten LaTeX-Datei auch so funktioniert. Dank.

Gruß, Tanata

von Xenara » Di 29. Jun 2010, 11:22

Dann würde mich nur noch interessieren, ob mein MB jetzt funktioniert hat oder nicht.

Problem mit Packet listings

von Tanata » Di 29. Jun 2010, 11:19

Habe noch einmal die Dokumentation zum Packet listings durchforstet und habe etwas gefunden. Für
texcl=true
in der folgenden Deklaration, also mit
\lstset{..., 
    texcl=true,
    ....}
tritt der Fehler im Minimalbeispiel nicht mehr auf. Ich verstehe es zwar nicht wirklich, aber es funktioniert und das ist gut so.

Danke fürs Zuhören.

Lieben Gruß
Tanata

von Xenara » Di 29. Jun 2010, 11:00

Jup, jetzt ist das nachvollziehbar :)

Hier der Code, wies bei mir funktioniert (ich musste nur für mein System utf8 auf latin1 ändern), es lag wie vermutet an extendedchars=false. Mit true klappts.
\documentclass[12pt,a4paper]{book} 
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}	
\usepackage[ngerman]{babel} 
\usepackage[usenames]{color} 
\usepackage{array} 
\usepackage{booktabs} 
\usepackage{longtable} 
\usepackage{listings} 

\lstdefinelanguage{VBA}{morekeywords={And, As, Byte, Call, Case, Compare, CDbl, Datebase, Date, Dim, Else, ElseIf, End, Error, Exit, Explicit, False, Function, GoTo, If, IIF, Integer, Not, Nothing, Null, Object, On, Option, Or, Private, Resume, String, Single, Select, Set, Static, Sub, Then, True, To,}, 
   sensitive=false, 
   morecomment=[l]Rem, 
   morecomment=[l]', 
   morestring=[b]", 
   emph={acFormBar, acEditMenu, acCurrent, acEntire, acMenuVer70, acSaveYes, acViewNormal, acForm, acDataErrAdded, acNewRec, acDataErrContinue, Cancel, CancelEvent, Close, CurrentDb, DefaultValue, DateValue, DAO, Description, DoCmd, DoMenuItem, Err, Error, Error$, $, Execute,  FindRecord, Forms, FindFirst, IsNull, Me, MsgBox, GoToControl, GoToRecord, NewData, Nz, Maximize, Number, OpenForm, Parent, Recordset, Requery, Response, SetFocus, stDocName, stLinkCriteria, Value, vbExclamation, vbOK, vbOKCancel, vbInformation, vbYes, vbNo, vbYesNo, vbCancel, vbQuestion, vbYesNoCancel, Visible,}, 
   emphstyle=\itshape} 
    
\lstloadlanguages{VBA,VBScript} 
\lstset{% 
   language=VBA, 
   basicstyle=\small, 
   keywordstyle=\color{blue}\bfseries, 
   commentstyle=\color{green}\itshape, 
   tabsize=1, 
   extendedchars=true, 
   inputencoding=latin1, 
   breaklines=true, 
   showstringspaces=false, 
   stringstyle=\sffamily, 
   numbers=left, 
   numberstyle=\tiny, 
   stepnumber=2, 
   numbersep=5pt} 

\begin{document} 
\begin{lstlisting} 
Rem Die in diesem Kommentar vorhandenen Umlaute, wie in für, ändern, Aufführung, werden nicht wie gewünscht gesetzt. 
\end{lstlisting} 
\end{document} 

Problem mit Packet listings

von Tanata » Di 29. Jun 2010, 11:00

Für den Fall
extendedchars=true
erhalte ich die Fehlermeldung
! Package inputenc Error: Unicode char \u8:\expandafter not set up for use with LaTeX
und
! Package inputenc Error: Keyboard character used is undefined
Damit kann ich nicht wirklich was anfangen. Habt ihr da eine Idee?

Gruß
Tanata

Problem mit Packet listings

von Tanata » Di 29. Jun 2010, 10:48

Verzeihung, hier ein komplettes Beispiel:
\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[usenames]{color}
\usepackage{array}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{listings}

\lstdefinelanguage{VBA}{morekeywords={And, As, Byte, Call, Case, Compare, CDbl, Datebase, Date, Dim, Else, ElseIf, End, Error, Exit, Explicit, False, Function, GoTo, If, IIF, Integer, Not, Nothing, Null, Object, On, Option, Or, Private, Resume, String, Single, Select, Set, Static, Sub, Then, True, To,},
	sensitive=false,
	morecomment=[l]Rem,
	morecomment=[l]',
	morestring=[b]",
	emph={acFormBar, acEditMenu, acCurrent, acEntire, acMenuVer70, acSaveYes, acViewNormal, acForm, acDataErrAdded, acNewRec, acDataErrContinue, Cancel, CancelEvent, Close, CurrentDb, DefaultValue, DateValue, DAO, Description, DoCmd, DoMenuItem, Err, Error, Error$, $, Execute,  FindRecord, Forms, FindFirst, IsNull, Me, MsgBox, GoToControl, GoToRecord, NewData, Nz, Maximize, Number, OpenForm, Parent, Recordset, Requery, Response, SetFocus, stDocName, stLinkCriteria, Value, vbExclamation, vbOK, vbOKCancel, vbInformation, vbYes, vbNo, vbYesNo, vbCancel, vbQuestion, vbYesNoCancel, Visible,},
	emphstyle=\itshape}
	
\lstloadlanguages{VBA,VBScript}
\lstset{%
	language=VBA,
	basicstyle=\small,
	keywordstyle=\color{blue}\bfseries,
	commentstyle=\color{green}\itshape,
	tabsize=1,
	extendedchars=false,
	inputencoding=utf8,
	breaklines=true,
	showstringspaces=false,
	stringstyle=\sffamily,
	numbers=left,
	numberstyle=\tiny,
	stepnumber=2,
	numbersep=5pt}

\begin{document}
\begin{lstlisting}
Rem Die in diesem Kommentar vorhandenen Umlaute, wie in für, ändern, Aufführung, werden nicht wie gewünscht gesetzt.
\end{lstlisting}
\end{document}
Könnt ihr den Fehler jetzt nachvollziehen?

Gruß
Tanata

Nach oben