TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

Am looking for an elegant way to include line numbers in my mdframed documents. Unfortunately, the following produces a 85 page docuement with \linenumbers (either before or after the \begin{mdframed}. Document is only 4 pages without the \linenumbers.


  • Am ok with a post processing solution, but was not able to get Jake's solution from Add page and line numbers to a pdf to work. And yes I know that saying "it doesn't work" does not help to figure out what the problem is -- might post a separate question, but thought that using lineno package would be easier.


        \draw [fill=yellow!25] (0,0) rectangle (3,4);
share|improve this question

marked as duplicate by Marco Daniel, Peter Grill, Kurt, Thorsten, Herbert Apr 5 '13 at 20:21

This question was marked as an exact duplicate of an existing question.

Is this of any help? – Jubobs Apr 5 '13 at 8:31
@Jubobs: Yeah I saw that question, but that seems more of a method of manually adding line numbers. I need an automated solution. – Peter Grill Apr 5 '13 at 8:54
Have you tried recycling some code for line numbering from the algorithm2e package? – Jubobs Apr 5 '13 at 9:01
@Jubobs: No have not, but sure if that would work, as the solution I need needs to work with TeX's line breaking algorithm, and I think those packages have their own. – Peter Grill Apr 5 '13 at 9:05
The issue isn't related to mdframed. A similar question with minipage can be found here: tex.stackexchange.com/questions/103163/… – Marco Daniel Apr 5 '13 at 17:25