Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle \linebreak #214

Closed
wants to merge 1 commit into from
Closed

Conversation

symphorien
Copy link
Contributor

No description provided.

@torik42 torik42 added the type: LaTeX Issues concerning supported or new LaTeX command or packages label Aug 21, 2022
@torik42
Copy link
Owner

torik42 commented Aug 22, 2022

For what do you use \linebreak? We also replace \\ and \newline only with a space ' '. I see no reason in adding one \n. And adding a whole paragraph is not what \linebreak does.

Even adding a space is only a good idea for \linebreak and \linebreak[4] which indeed force a line-break (here, it is indeed a good idea). But for \linebreak[n] with n=0,1,2,3, this can produce false negatives, when the line break does not happen, e.g., There\linebreak[0]is a missing space. And I assume, this is much more common, than a wrong line break, e.g., Thi\linebreak[4]s is a wrong line break (at least for n<4). And I see no way to determine where LaTeX inserts the line break.

@symphorien
Copy link
Contributor Author

I tried replacing with an empty string, but then \linebreak without argument eats the space.

@torik42
Copy link
Owner

torik42 commented Aug 23, 2022

I see. That’s also what LaTeX does, if you define a command \newcommand{\test}[1][]{} and write A\test B. With the difference, that \linebreak without argument will insert a line break.

If I understand correctly, you would be fine with

source output
A\linebreak B A B
A\linebreak[4]B, A\linebreak [4]B A B
A\linebreak[n]B, A\linebreak [n]B (n<4) AB

This should be doable with Macro(…) definitions. I’ll have a look later.

I see a problem with A\linebreak\linebreak B though, which leaves an empty line in the PDF. The same happens for \\. I might open a separate issue for that.

torik42 added a commit that referenced this pull request Aug 23, 2022
as suggested in PR #214, but with different implementation
@torik42
Copy link
Owner

torik42 commented Aug 23, 2022

I added another branch with an implementation that seems to work. I think only 0,1,2,3 and 4 are allowed, although LaTeX doesn’t complain when using other numbers (and interprets all of them as 4). I now allow the above mentioned numbers (plus extra white space) and write an LATEXXXERROR if something else is provided. You can try it out in the add-linebreak branch.

Does that work for you?

@symphorien
Copy link
Contributor Author

Honestly I forgot my original use case, so please go for it, by all means!

@symphorien symphorien closed this Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: LaTeX Issues concerning supported or new LaTeX command or packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants