PhelypeOleinik / lipsum

150 paragraphs of Lorem ipsum dummy text for LaTeX
12 stars 7 forks source link

lipsum and hyperref interaction after the latest upgrade #7

Closed gusbrs closed 3 years ago

gusbrs commented 3 years ago

Hi Phelype,

the latest upgrade brought some kind of interaction with hyperref and currently, I'm having trouble using lipsum text as a \hyperref or \hyperlink argument. The MWE illustrates:

\documentclass{book}

\usepackage{lipsum}
\usepackage{hyperref}

\begin{document}

\chapter{Chapter 1}
\label{cha:chapter-1}

\section{Section 1}
\label{sec:section-1}

\hyperref[sec:section-1]{\lipsum[6]}

\end{document}

Compilation of the above document results in error:

./test.tex:14: pdfTeX error (ext1): \pdfendlink cannot be used in vertical mode
.
\close@pdflink ...\Hy@VerboseLinkStop \pdfendlink 

l.14 \hyperref[sec:section-1]{\lipsum[6]}

This did not happen before this week's upgrade.

PhelypeOleinik commented 3 years ago

This was an intentional change (though I didn't expect it to break this bad :)

Previous versions of lipsum used the \par token as a separator between paragraphs, so \lipsum[1-2] would be <paragraph 1>\par<paragraph 2>. The change I did is to instead of a separator, the \par token is used instead at the end of each paragraph, so <paragraph 1>\par<paragraph 2>\par, adding an extra \par there that shouldn't be harmless.

In your case you are using a single paragraph, so the change of course added an extra \par at the end, and \hyperref tries to and the link in vertical mode and pdfTeX doesn't like that.


On the one hand, I think your input is fundamentally wrong, because \lipsum (with only one optional argument) is advertised to produce paragraphs, and you are using it in a command that doesn't like paragraph breaks, so I'd argue that the correct input would be \lipsum*[6], which is documented to add no \par between paragraphs (rather at the end of paragraphs now), or \lipsum[6][-], which puts \lipsum in sentence mode, producing a bunch of sentences instead.

On the other hand, the new behaviour is also weird, because hello \lipsum[1] world produces two paragraphs, which is weird: I think it should either be one or three, so here I'd prefer the old behaviour of not adding \par at the end.

So I'm not sure I should revert this change or what... I'd love arguments to either option :)


Meanwhile, you can restore the old behaviour (\par as a separator, not at the end) with:

\setlipsum{par-end={},par-sep=\par}
gusbrs commented 3 years ago

Ah, that explains what happened and why it changed. Thank you very much! Since it is documented, I think it is fine, I was just caught off guard by the change.

But, since you asked for thoughts, the case were I met the issue might be of some use. I was actually testing some fresh code of mine, and using lipsum in a test document. Things were working, but then, after some refactoring, all of a sudden no longer so. Of course, in this case I was my own immediate suspect, but it did cost me quite a lot of debugging to pin it down to the lipsum upgrade. True, you are right in arguing the behavior is documented and hence expected. But, if it so happens that people use lipsum in testfiles (I have no idea what the practice in this regard is), you might have a case to bring in some backward compatibility considerations to weight in.

Btw, do feel free to close this issue. The explanation you provided is more than enough to clear this as an user error.

PhelypeOleinik commented 3 years ago

I was just caught off guard by the change.

Sorry about that!

I was actually testing some fresh code of mine, and using lipsum in a test document. Things were working, but then, after some refactoring, all of a sudden no longer so.

All the use cases I had in mind when I did this change were “plain typesetting” of lipsum paragraphs, so I didn't expect this to have this much impact.

The explanation you provided is more than enough to clear this as an user error.

I'm not so convinced... I had a one-sided thinking about this issue regarding usage like \lipsum[1-2] hello, but completely ignored something simpler like hello \lipsum[1] world, which makes complete sense if typeset as a single paragraph. I think neither option is completely good, but for the sake of backwards compatibility I may end up rolling back this change (I'm not sure yet, but it is likely, so I'll leave this issue open).

Anyhow, to ensure the old behaviour you can use \setlipsum{par-end={},par-sep=\par} as I said above: this will ensure that \par is used as a separator, rather than inserted at the end of each paragraph. This will work, regardless of what default the package has, so you can go with that option to be on the safe side.

gusbrs commented 3 years ago

I was actually testing some fresh code of mine, and using lipsum in a test document. Things were working, but then, after some refactoring, all of a sudden no longer so.

All the use cases I had in mind when I did this change were “plain typesetting” of lipsum paragraphs, so I didn't expect this to have this much impact.

The truth is, I have no idea of the uses people make of lipsum, beyond the traditional MWE at TeX.SX, of course. I'd say my use case here is not really that far from "plain typesetting", though... And, as said, if you know people to use this in regression tests, you should probably take this into consideration (but I don't know if they do).

The explanation you provided is more than enough to clear this as an user error.

I'm not so convinced... I had a one-sided thinking about this issue regarding usage like \lipsum[1-2] hello, but completely ignored something simpler like hello \lipsum[1] world, which makes complete sense if typeset as a single paragraph. I think neither option is completely good, but for the sake of backwards compatibility I may end up rolling back this change.

Well, since it is documented and intended, if I used it otherwise, it is on me. That is what I meant. Of course, there's still the question whether the documented / intended behavior is the best choice. And I admit I think the previous behavior felt "more intuitive" to me. Indeed, why the stray \par? But I do get that you are striving for a more logical organization of the options, and grant that it is also an interesting stance in that regard. All in all, I don't have a strong opinion either way.

(I'm not sure yet, but it is likely, so I'll leave this issue open).

Yes, what I meant is that it is up to you. I'm not dismissing the issue, just saying I don't claim this to be a misbehavior, and whether you want to pursue this further is your call. And that I won't be troubled if you choose not to.

gusbrs commented 3 years ago

I had a one-sided thinking about this issue regarding usage like \lipsum[1-2] hello, but completely ignored something simpler like hello \lipsum[1] world, which makes complete sense if typeset as a single paragraph. I think neither option is completely good, [...].

Phelype, I think I have a good argument for the previous default. Besides backward compatibility, that is. I agree the two cases you mentioned in the above sentence are both valid /sensible use cases, and equally arbitrary. However, there is an asymmetry at play: it is much easier to add a paragraph, if you miss one, than it is to remove one, if you don't want it. So, for an usage like \lipsum[1-2] hello no user will think twice to just do:

\lipsum[1-2]

hello

Whereas to "fix" the second case -- hello \lipsum[1] world -- things become more difficult. Now a visit to the manual is required. And using myself as example, though I have used lipsum for quite some time to build MWEs, I hadn't the faintest idea a starred version of \lipsum existed, and even less so what it did.

gusbrs commented 3 years ago

Thank you!