Text FormattingLine break problem with enumerate

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

Line break problem with enumerate

Post by Phantomias »

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:

Code: Select all

\begin{enumerate}
\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
\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.
\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!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

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

Line break problem with enumerate

Post by Phantomias »

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!
thomasb
Posts: 134
Joined: Thu Aug 03, 2017 10:54 am

Line break problem with enumerate

Post by thomasb »

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

Line break problem with enumerate

Post by Phantomias »

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: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Line break problem with enumerate

Post by Stefan Kottwitz »

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
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Line break problem with enumerate

Post by Stefan Kottwitz »

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

Code: Select all

\documentclass{article}
\usepackage{xparse}
\newcommand{\breakpoint}{\discretionary{}{}{}}
\ExplSyntaxOn
\NewDocumentCommand{\dotbreak}{m}
 {
  \tl_set:Nn \l_tmpa_tl { #1 }
  \tl_replace_all:Nnn \l_tmpa_tl { . } { .\breakpoint }
  \tl_replace_all:Nnn \l_tmpa_tl { ; } { ;\breakpoint }
  \tl_replace_all:Nnn \l_tmpa_tl { * } { *\breakpoint }
  `\tl_use:N \l_tmpa_tl'
 }
\ExplSyntaxOff
\begin{document}
\begin{enumerate}
\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}
\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.
\end{enumerate}
\end{document}
Looks much better though not perfect yet.

Stefan
LaTeX.org admin
Phantomias
Posts: 7
Joined: Tue Nov 15, 2011 10:11 pm

Line break problem with enumerate

Post by Phantomias »

@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 :)
Post Reply