LaTeX forum ⇒ Text FormattingLine break problem with enumerate Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Phantomias
Posts: 7
Joined: Tue Nov 15, 2011 10:11 pm
Location: France

Line break problem with enumerate

Postby Phantomias » Thu Jul 27, 2017 3:12 pm

Hello everyone,

unfortunately I have a problem with line breaks while using enumerate to make a numbered list.
I'm not that experienced with Latex and there seems to be a problem (for me) while using many symbols like ;|.* etc. within an enumerate block.

This is some example code:
  1. \begin{enumerate}
  2. \item test.hello.why.this.doesn't.work;*;;.\textbar test.hello.why.this.doesn't.work;*;;.\textbar test.hello.why.this.doesn't.work;*;;.\textbar test.hello.why.this.doesn't.work;*;;.\textbar test.hello.why.this.doesn't.work;*;;. \textbar test.hello.why.this.doesn't.work;*;;.\textbar test.hello.why.this.doesn't.work;*;;.\textbar
  3. \item test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work.
  4. \end{enumerate}


For the first item of the enumerate list the line wrap doesn't work, it just gets cut off at the margin of the page.
For the second item the line wrap works just like it should.

Is there any way to make it work for the first item?

Thank you in advance!

Phantomias
Posts: 7
Joined: Tue Nov 15, 2011 10:11 pm
Location: France

Postby Phantomias » Thu Aug 03, 2017 11:15 am

I still couldn't figure out how to solve this issue... Is there no way to get the first item to do proper line breaking? I understand that there must be a problem with all the symbols in the first item as there is no issue with the second one but how can it be done?

Does nobody have any ideas? :/

Thanks again!

User avatar
thomasb
Posts: 76
Joined: Thu Aug 03, 2017 10:54 am
Location: france

Postby thomasb » Thu Aug 03, 2017 4:55 pm

Salut,
Où est le souci, de ne pas aller à la ligne ? Si tu coupes la première chaîne ici ou là, tu vas voir des retours à la ligne.
Et sinon, si les césures ne se font pas au bon endroit, tu peux les forcer avec la commande \- à l'intérieur du mot.

Phantomias
Posts: 7
Joined: Tue Nov 15, 2011 10:11 pm
Location: France

Postby Phantomias » Fri Aug 04, 2017 11:31 am

Thank you for your answer,

unfortunately my french is very limited as I'm only living here for some time.
The problem is that the line breaking should be done by Latex (at least I'd like Latex to do it automatically) or else it would look pretty bad (different line lengths). Also, I got way too many strings like shown in the first item. It would take me hours if I manually put line breaks everywhere... Is there no way to make Latex do it like it does with everything else?

Thanks

User avatar
Stefan Kottwitz
Site Admin
Posts: 8523
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Fri Aug 04, 2017 6:27 pm

This is an english forum where other people read too, so it would be great if we would continue posting in English only.

By the way, out partner site TeXnique.fr is in French, it would be great if you would join us there too!

Stefan
Site admin

User avatar
Stefan Kottwitz
Site Admin
Posts: 8523
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Fri Aug 04, 2017 6:29 pm

Here is a way that adds possible breakpoints to certain characters, such as to the dot.

  1. \documentclass{article}
  2. \usepackage{xparse}
  3. \newcommand{\breakpoint}{\discretionary{}{}{}}
  4. \ExplSyntaxOn
  5. \NewDocumentCommand{\dotbreak}{m}
  6. {
  7. \tl_set:Nn \l_tmpa_tl { #1 }
  8. \tl_replace_all:Nnn \l_tmpa_tl { . } { .\breakpoint }
  9. \tl_replace_all:Nnn \l_tmpa_tl { ; } { ;\breakpoint }
  10. \tl_replace_all:Nnn \l_tmpa_tl { * } { *\breakpoint }
  11. `\tl_use:N \l_tmpa_tl'
  12. }
  13. \ExplSyntaxOff
  14. \begin{document}
  15. \begin{enumerate}
  16. \item \dotbreak{test.hello.why.this.doesn't.work;*;;.\textbar test.hello.why.this.doesn't.work;*;;.\textbar test.hello.why.this.doesn't.work;*;;.\textbar test.hello.why.this.doesn't.work;*;;.\textbar test.hello.why.this.doesn't.work;*;;. \textbar test.hello.why.this.doesn't.work;*;;.\textbar test.hello.why.this.doesn't.work;*;;.\textbar}
  17. \item test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work test hello why this DOES work.
  18. \end{enumerate}
  19. \end{document}


Looks much better though not perfect yet.

Stefan
Site admin

Phantomias
Posts: 7
Joined: Tue Nov 15, 2011 10:11 pm
Location: France

Postby Phantomias » Tue Aug 15, 2017 10:29 am

@Stefan Kottwitz
Thank you for your answer, seems like this function works just fine for my purpose. Much better than manually ruining Latex's format style. Thanks for the help :)


Return to “Text Formatting”

Who is online

Users browsing this forum: Exabot [Bot] and 6 guests