# Why is the ledmac line number misaligned with the final item?

Here's a minimal document showing the problem:

\documentclass{article}

\usepackage{ledmac}

\begin{document}

\firstlinenum{1}
\linenumincrement{1}
\beginnumbering
\pstart
\begin{itemize}
\item This item aligns with the line number...
\item ... but the line number is far below this item.
\end{itemize}
\pend
\endnumbering

\end{document}


The document turns out like this:

1 · This item aligns with the line number...
· ... but the line number is far below this item.
2


Note that:

a) it's always the last item in a list,

b) the line is aligned if you add a newline (\\) at the end of the last item (but you get another line number, which looks odd),

c) the line is aligned if you add text between \end{itemize} and \pend,

d) and the line is not aligned if you simply add text after \pend.

So why does this happen and how can I fix the problem?

-

You can use the

\beginnumbering
\pstart
...
\pend
\endnumbering


block inside the itemize environment:

\documentclass{article}
\usepackage{ledmac}

\begin{document}

\firstlinenum{1}
\linenumincrement{1}
\begin{itemize}
\beginnumbering
\pstart
\item This item aligns with the line number...
\item ... but the line number is far below this item.
\pend
\endnumbering
\end{itemize}

\end{document}


EDIT: I am astonished; after reading the comments to my answer, I was doing some tests and now the following example code (which is basically the same as the example code in the question) compiles OK and behaves as expected!

\documentclass{article}
\usepackage{ledmac}

\begin{document}

text text text text text text text  text text text  text text text  text text text  text text text  text text text  text text text  text text text  text text text  text text text  text text text  text text text  text text text  text text text
\firstlinenum{1}
\linenumincrement{1}
\beginnumbering
\pstart
\begin{itemize}
\item This item aligns with the line number...
\item This item also aligns with the line number...
\end{itemize}
\pend
\endnumbering

\end{document}


Here's the result:

I'll investigate what is going on!

EDIT2: Finally I discovered what's going on, but I don't know the reason behind the problem... it seems like a bug in ledmac. The problem is related to the length of the text in each item. You can see this with the following example:

\documentclass{article}
\usepackage{ledmac}

\begin{document}

\firstlinenum{1}
\linenumincrement{1}
\beginnumbering
\pstart
\begin{itemize}
\item This item aligns with the line number...
\item This item also aligns ...
\item This doesn't ... % but it will align if you add this text
\end{itemize}
\pend
\endnumbering

\end{document}


Compile the example as it is and you will see the strange behaviour described in the question; here's an image of the result:

Now, delete the comment character and compile again and you will get the expected result:

The same strange results will be observed if enough text is added to the second item of the example code in the question.

I think you should write a note to the package creators.

-
True. But it also introduces a horizontal alignment problem. If you look at the output of your example, you will see there is very little space between the line number and the bullet point. Add a bit of text before the itemize environment to convince yourself that it's a problem. –  Jon Ericson Jun 6 '11 at 23:28
Also, I tested moving \pstart and \pend inside the environment, which still had the horizontal alignment issue. Moving the \beginnumbering and \endnumbering has an additional problem of resetting the numbering at the start of the itemize environment, which I don't want. –  Jon Ericson Jun 6 '11 at 23:31
@Jon Ericson: I've updated my answer with a (surprisingly) working example. I'll try to determine what is happening. –  Gonzalo Medina Jun 7 '11 at 0:14
I'm seeing that too. But I can't grok what the difference is nor apply the answer to my (very) non-minimal document. I wonder if it has something to do with what's written to the .aux or .1 or .end files? –  Jon Ericson Jun 7 '11 at 0:41
And to answer my own question: no. I created two separate test files with the only difference being the content of the second item and I can't figure out why the alignment gets screwed up in the original and not your version. They should be the same! –  Jon Ericson Jun 7 '11 at 1:06

Based on Gonzalo Medina's excellent (and accepted) answer, I've sent Peter Wilson, the author of the ledmac package, an email explaining the problem. If and when there's a bug fix, I'll update this answer with the details.

In addition, his answer guided me to a temporary workaround for the test case in the question without printing bogus text to extend the line. Use the \phantom macro:

\begin{itemize}
\item This item aligns with the line number...
\item ... and the line number is not below this item.\phantom{extra text to pad the line}
\end{itemize}


The result is:

1 · This item aligns with the line number...
2 · ... and the line number is not below this item.

-