Text FormattingFailure to word-wrap inside enumerate environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
ptrcao
Posts: 88
Joined: Sun Dec 05, 2010 3:26 am

Failure to word-wrap inside enumerate environment

Post by ptrcao »

Once again, I find some lines are not wrapping properly, for no obvious reason. It doesn't happen for every item, just these particular ones. As you can see below, the margins are not being respected:
CDN.gif
CDN.gif (57.94 KiB) Viewed 8846 times

Code: Select all

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{verbatim} %for commenting
\usepackage[hyphens]{url}
\usepackage{xcolor}
\usepackage[urlbordercolor=blue]{hyperref}
\usepackage{breakurl}

\title{SRS}
\author{Peter Cao}

\begin{document}

...

\section{Performance Levels}
\begin{enumerate}
\item It should be very fast light-weight program, which shows changes in real-time and incurs no waiting on the part of the user.
\item Given the real-time role of MathJax in reflecting changes by the user, a careful study of MathJax's processes will be necessary, particularly loading behaviour.  The MathJax engine is known to take a long time to start up.  Speed would be abysmally implicated if the MathJax engine has to reload from scratch every time it is invoked; this would be entirely unnecessary.  A way would need to be found to maintain MathJax on standby, rather than have its engine restart for every mark-up change that is made.  In other words, new information would need to be retrieved in Ajax fashion, so that previously loaded information need not be reloaded unnecessarily.
\item Buttons should function asynchronously to keep up with dexterous, practised users.
\item It should require very little resources and have the fewest software pre-requisites on the client end, thereby ensuring the widest accessibility.  It should run efficiently on the widest spectrum of operating environments and situations as possible.
\item To the extent that we are recruiting MathJax, the availability of JavaScript support seems unavoidable.
\item MathJax can either be sourced from my hosting server or MathJax CDN \url{http://cdn.mathjax.org/mathjax/1.1-beta/MathJax.js}.  See \url{https://sites.google.com/site/mathjaxproject/design-documents/cdn-hosting-plan} for more information.
\end{enumerate}

\section{Data Structures/Elements}
...
and
javascript-failed-to-wrap.gif
javascript-failed-to-wrap.gif (21.52 KiB) Viewed 8846 times

Code: Select all

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{verbatim} %for commenting
\usepackage[hyphens]{url}
\usepackage{xcolor}
\usepackage[urlbordercolor=blue]{hyperref}
\usepackage{breakurl}

\title{SRS}
\author{Peter Cao}

\begin{document}

...

Protectionist measures:
\begin{enumerate}
\item Appropriate licensing.  The programmer should inform me about the best options, as I am unfamiliar with the various licence classes and their implications for use by third parties.
\item Originally, it was entertained that the script could be concealed from users.  To the extent JavaScript will be used for the front-end interface, this seems unlikely, since JavaScript is an inherently revealing mode of coding.  Perhaps alternative means of delivery could be used, but it seems an unjustifiable length to go to just to have the script concealed.
\end{enumerate}

\section{Other required forum functions}

...
Given the complete picture now, do you know why and what is the solution to force the offending items back into line?
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Failure to word-wrap inside enumerate environment

Post by Stefan Kottwitz »

Hi ptrcaro,

you could allow line breaks at more places. Here's an example which is a bit extreme, allowing breaks also at lowercase letters:

Code: Select all

\expandafter\def\expandafter\UrlBreaks\expandafter{\UrlBreaks\do\a%
\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j\do\k\do\l\do\m\do\n%
\do\o\do\p\do\q\do\r\do\s\do\t\do\u\do\v\do\w\do\x\do\y\do\z\do\&}
I extended the command \Urlbreaks this way. Since hyperref provides this funtionality, I would remove \usepackage[hyphens]{url}.

I got the attached output.
breaklinks.png
breaklinks.png (9 KiB) Viewed 8836 times
Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Failure to word-wrap inside enumerate environment

Post by Stefan Kottwitz »

Now saw, besides hyperlinks also normal words make problems in word-wrapping. You could use \hyphenation, for example:

Code: Select all

\hyphenation{Java-Script}
Now JavaScript can be broken at the end of a line.

Stefan
LaTeX.org admin
ptrcao
Posts: 88
Joined: Sun Dec 05, 2010 3:26 am

Re: Failure to word-wrap inside enumerate environment

Post by ptrcao »

Great suggestions Stefan_K.

Though, I was hoping for automatic solutions; I deal with some pretty long documents, and I really would rather avoid having to manually go through and clean up every instance. I was hoping that you could just modify the packages in the preamble in a way that would more globally fix this problem.

Do you or anyone else have a way to implement this automatically and affect all instances at once?
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Failure to word-wrap inside enumerate environment

Post by Stefan Kottwitz »

Global solutions:
  • Use babel with language option:

    Code: Select all

    \usepackage[english]{babel}
    Depending on the language (USenglish, UKenglish) the hyphenation can be improved. For example, if I use ngerman, even JavaScript would be wrapped.
  • use T1 font encoding to properly handle special characters such as accented characters, improving hyphenation:

    Code: Select all

    \usepackage[T1]{fontenc}
  • Load microtype, it's font expansion and character protrusion improve justification. Here, JavaScript would be moved to the next line, the line before would be a bit stretched.

    Code: Select all

    \usepackage{microtype}
  • Check out l2tabu for adjusting certain parameters such as penalties.
  • For special words, like scientific or technical expressions which TeX cannot handle well, use \hyphenation once in the preamble. All occurences in the text would be affected.
  • use the draft option to easily locate overfull hboxes, bad justification, look at the warnings which will show problematic words where you should use \hyphenation.
Stefan
LaTeX.org admin
Post Reply