2

I tried to define a few PowerShell cmdlets for the lstlisting environment, but it seems that the - breaks the definition. So when I try:

\lstdefinelanguage{powershell}{
    keywords = {Get-AzureSubscription,Get-Host,anything}
}

only the keyword anything is detected. Do I have to escape the -, and how?

Thanks for any help.

2

As Marijn said in his comment you should add alsodigit = {-} in your definition:

\documentclass{report}
\usepackage{listings}

\lstdefinelanguage{powershell}{
    alsodigit = {-},
    keywords = {Get-AzureSubscription,Get-Host,anything}
}

\begin{document}
\begin{lstlisting}[language=powershell]
text anything Get-AzureSubscription
\end{lstlisting}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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