1

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.

1 Answer 1

1

You can solve the problem by saying

\defµ{\ensuremath{\mu}}

in your preamble (after having loaded inputenc).

2
  • thank you! Might this definition have an effect onto other usages of "µ" or $\mu$ in the document? Jul 13, 2011 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, 2011 at 9:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .