I'm currently creating my diploma thesis, and used PowerShell to do some of the described work. I'd like to also put some of this code into the thesis and would therefore like to have syntax highlighting.

I've found several predefined languages defined in the listings package (http://texdoc.net/texmf-dist/doc/latex/listings/listings.pdf)

Unfortunately PowerShell is not present. I'm wondering whether there is any package or "listings-powershell.prf" file available... Is there?

In case there is, could you please post the link? Otherwise, I will use \lstset and customize the listing.

  • Welcome to TeX.SX! You don't have to sign with your name since it automatically appears in the lower right corner of your post. – jub0bs May 15 '15 at 12:37
  • You're right, listings doesn't come with a definition for PowerShell. Because I'm no PowerShell user, I can't define a listings language for it myself, but I invite you to visit this and search for "bash, csh, and sh". That will lead you to the listings definitions for those three shells, which you can adapt for PowerShell; just make sure to use the user macro \lstdefinelanguage instead of the internal macro lst@definelanguage. – jub0bs May 15 '15 at 12:41
  • Give it your best shot. If you run into trouble and get stuck somewhere, you can always edit your question to make it more specific. People here will be happy to help you along. And once you're happy with the result, I encourage you to submit the language definition to the maintainer of listings, so it can be included in a future release of that package. – jub0bs May 15 '15 at 12:41
  • It is probably because no-one have ever made a language setting for it (for highlighting). So you may have to write your own language specification for Powershell. You can see examples in lstlang1.sty, lstlang2.sty and lstlang3.sty – daleif May 15 '15 at 12:42
  • You may find this answer of mine useful for defining a Powershell language for listings. – jub0bs May 15 '15 at 12:46

Your Answer

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

Browse other questions tagged or ask your own question.