I am looking for a way to mark some lines in a source code sample that will be integrated into my LaTeX code.

I already found solutions to embed source code and have syntax highlighting like this solution: Including XML file into LaTeX But this is not exactly what I need. Imagine a source code file I include (XML, if this may be important in any way) and I only want to highlight lines 14, 15 and a part of line 16. I already thought about putting my code in word or open office writer and mark it there and include a screenshot instread of the code-file but there must be a better solution than this.

Anyone can help?


You could try something like:





Solution pulled from Highlight text in code listing while also keeping syntax highlighting.

  • If you directly copy and paste the url of a question/answer, it automatically appears the title. Oct 20 '13 at 11:40
  • One downside of this approach is that it forces you to place delimiters in the listing. That's particularly undesirable when \lstinputlisting is used.
    – jub0bs
    Oct 20 '13 at 11:47

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.