2

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.

8
  • 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, 2015 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, 2015 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, 2015 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, 2015 at 12:42
  • You may find this answer of mine useful for defining a Powershell language for listings.
    – jub0bs
    May 15, 2015 at 12:46

1 Answer 1

1

Someone wrote the language specification for PowerShell. Have a look here: https://github.com/rmainer/latex-listings-powershell/blob/master/src/latex-listings-powershell.tex

1
  • 1
    Welcome to TSE. This should be a comment, not an answer. Jun 8, 2022 at 14:16

You must log in to answer this question.

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