lierdakil / pandoc-crossref

Pandoc filter for cross-references
https://lierdakil.github.io/pandoc-crossref/
GNU General Public License v2.0
909 stars 73 forks source link

Use `listing` instead of `codelisting` #417

Open kchousos opened 6 months ago

kchousos commented 6 months ago

Greetings.

First of all, I would like to thank you for your contribution and your handy filter. It has been a real life saver for when I need to write uni reports and the like.

My question is: Is it possible to output the listing environment for captioned code blocks, instead of the filter's custom codelisting? I am using this filter in conjunction to minted.lua. I've already set up my code blocks to look how I like them, but I would like for my captioned code blocks to have the same formatting. Would something like that be possible? Thanks in advance.

lierdakil commented 6 months ago

Yes, it's possible, see the listings option in the manual: https://lierdakil.github.io/pandoc-crossref/#general-options. Please note that Pandoc doesn't use listing by default either, so you have to invoke pandoc -F pandoc-crossref -Mlistings --listings or something equivalent (see the pandoc manual for details)

kchousos commented 6 months ago

Your solution is meant for usage with the package listings. I want to use minted, which uses the environment listing, instead of lstlisting that the first one uses.

lierdakil commented 6 months ago

Okay. The best I can suggest is to use --listings with a custom LaTeX template and just \newenvironment redefine lstlisting to mean listing. Not sure if it'll work well (or at all), but seems quite feasible. Another option is to use a small custom filter to rewrite all code blocks into the LaTeX code of your preference. Pandoc itself is quite limited in what LaTeX it will produce, so I don't really see many other options.