Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to include the code of some script in my LaTeX document. In a "minimal" example, it works perfectly well - but only if I leave out the line \usepackage[latin1]{inputenc}:

\documentclass[]{scrbook}
\usepackage{listings}
\usepackage{xcolor}

\usepackage[latin1]{inputenc}

\begin{document}

% % % % Definitionen der Code-Darstellung mit listings-Package
\lstset
{breaklines=true,
    tabsize=3,
    showstringspaces=false}

\lstdefinestyle{VBACommon}
{extendedchars=true,
    language={[Visual]Basic},
    frame=single,
    %===========================================================
    framesep=3pt,%expand outward.
    framerule=0.4pt,%expand outward.
    xleftmargin=3.4pt,%make the frame fits in the text area. 
    xrightmargin=3.4pt,%make the frame fits in the text area.
    %=========================================================== 
    %rulecolor=\color{Black}
}

\lstdefinestyle{A}
{style=VBACommon,
%    backgroundcolor=\color{Yellow!10},
    basicstyle=\scriptsize,
    keywordstyle=\bfseries,
    identifierstyle=\scshape,
    stringstyle=\ttfamily,
    commentstyle=\color{grau}
}



\lstdefinestyle{B}
{style=A,
%    backgroundcolor=\color{Yellow!10},
    language=VBScript,
    basicstyle=\scriptsize,
    keywordstyle=\bfseries,
    identifierstyle=\scshape,
    stringstyle=\ttfamily,
    commentstyle=%\color{}
}

\lstinputlisting[style=B]{/Volumes/Daten/Martin/FZK-Diss/Daten/_DISSschrift/Diss/ProgrammCode/VBScript/LIB_AcquireScriptingMB.wsf}

\end{document}

The input file looks like that and is (says my text editor) in TextEncoding ISO Latin 1:

  If dblPunkteX = dblPunkteY and dblRangeX = dblRangeY then
                strSchrittweite = "dxy" & dblPunkteX & "µm"'(dblSchrittweiteBerechnen(dblRangeX, dblPunkteX))
     else strSchrittweite = "dx" & dblPunkteX & "µm" & "_dy" & dblPunkteY & "µm" '& dblSchrittweiteBerechnen(dblRangeX, intPunkteX) &
"dy" & dblSchrittweiteBerechnen(dblRangeY, intPunkteY)   end if  
'Rueckgabewert   strDateinameErstellenAut =  strVerz & strTeilBez &
intZaehler & "-" & strTeilZust & "-" _
                  & strMessPos & "_" & strMessbereich & "_" & strSchrittweite End Function

I get error messages like that - it seems to be the quotation signs " or the µs:

(/usr/local/texlive/2010/texmf-dist/tex/latex/listings/lstlang2.sty)
/Volumes/Daten/Martin/FZK-Diss/Daten/_DISSschrift/Diss/ProgrammCode/VBScript/LI
B_AcquireScriptingMB2.wsf:3: Extra }, or forgotten $. \lst@OutputToken
...@token \@empty \lst@righthss }
                                                  \lst@CalcLostSpaceAndOutpu... 3 ...strSchrittweite = "dxy" &
dblPunkteX & "µm"
                                                  '(dblSchrittweiteBerechnen...

?

Unfortunately I don't know how to fix that, as I need the inputenc for other purposes.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You can solve the problem by saying

\defµ{\ensuremath{\mu}}

in your preamble (after having loaded inputenc).

share|improve this answer
    
thank you! Might this definition have an effect onto other usages of "µ" or $\mu$ in the document? –  Martin Jul 13 '11 at 9:40
    
It shouldn't; the normal definition of µ is just \mu and this is the cause of the error; the \ensuremath will do nothing in math mode. –  egreg Jul 13 '11 at 9:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.