I want to automate source code examples in my documentation. Listing comes very close to doing this as it allows specification of start and ending line numbers:


See: Using \lstinputlisting to include a file but only certain lines or line ranges

However, source code tends to be a living document. I would love some way to markup my code with some kind of EXAMPLE_BEGIN and EXAMPLE_END type of tag in the comments and let that define the bounds for the listing.

If this isn't possible with a current package, I'm not opposed to writing one that does this. If that's the case, is there a good starting point? (i.e. Modifying Listing? Modifying Minted? Parsing with a macro?)

1 Answer 1


Quoted from listings documentation:.

Instead of using linerange with line numbers, one can use text markers. Each such marker consists of a , , and a . You once (or more) define prefixes and suffixes and then use the marker text instead of the line numbers.



  Here some text which will not be included
  1. All these texts will be included
  2. All these texts will be included
  3. All these texts will be included
  Here some text as well which will not be included




enter image description here

(Those shifts must be coming from the default language settings.)

For more details please see Section 6.8 Multicolumn Listings in listings documentation.

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.