9

Consider the following code block:

~~~~{.Python .numberLines caption="test"}
def myfunction(var):
  """ Oh how awesome this is. """
  pass
~~~~

The code gets formatted correctly in the Pdf, but the caption does not appear. I also want to reference to the code block - but how? Can somebody give me a working example?

closed as off-topic by Kurt, lockstep, Thorsten, Martin Schröder, dustin Aug 7 '13 at 18:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center." – Kurt, lockstep, Thorsten, Martin Schröder, dustin
If this question can be reworded to fit the rules in the help center, please edit the question.

14

Nevermind, I found a way to do it. I was using the builtin code highlighter.

Setting the --listings flag, I can switch to the lstlistings package and use the following syntax:

~~~~{caption="The preprocessing step" label=lstpreprocess}
def myfunction(var):
  """ Oh how awesome this is. """
  pass
~~~~

Pandoc is awesome.

  • Is it also possible to number these lines? – lf_araujo Sep 8 '16 at 4:39
  • You could try numbers=left as a parameter. Did not test that, though. – mre Sep 8 '16 at 14:55

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