Here is a way to do it using references, and consequently at least two compilations. It requires using labelwidth
rather than widest
. First, some background...
The obvious motivation behind itemize
and description
providing solutions to this without problem is because the former (itemize
) uses a single-element (symbol) to denote list items, all of which have the same width (by default). Overriding this default to anything other than a single-element (symbol) will have misaligned items, or item labels protruding margin lines:
\begin{itemize}
\item An item
\item[qwerty] An item
\item An item
\end{itemize}
This is due to the left-aligned nature of the itemized bullets. Another motivation is because lists are typeset "on the fly" and even allow for page breaks between items. So, in order to know the widest item at the start, the entire enumerate
environment body would have to be read in memory/parsed before determining the widest, and then typeset - not the case by default. The latter (description
) works because it uses a right-aligned approach to typesetting the itemized bullets and has a paragraph-style typesetting of the label and item contents by default.
The solution using enumerate
requires setting the following enumitem
options for a list:
labelindent=0pt
: to have a flush left margin;
labelwidth=\widthof{\ref{last-item}}
: this requires the calc
package that measures the width of \ref{last-item}
where last-item
is a label set for the last item in your list;
label=\arabic*.
: labels will be arabic, followed by a period .
;
itemindent=1em
: separation/space between label and item; and
leftmargin=!
: automatically calculate what the leftmargin
should be based on the provided parameters above (this is new to version 3.0 of enumitem
).
Here is a minimal example highlighting the result:
\documentclass{article}
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\usepackage{calc}% http://ctan.org/pkg/calc
\begin{document}
\noindent Just enough text to make the line break so we get to see a second line.
\begin{enumerate}[labelindent=0pt,labelwidth=\widthof{\ref{last-item}},label=\arabic*.,itemindent=1em,leftmargin=!]
\item An item
\item An item
\item An item \addtocounter{enumi}{9997}
\item An item \label{last-item}
\end{enumerate}
Just enough text to make the line break so we get to see a second line.
\end{document}
Yikes! I guess since I posted that template I can answer. You'll note that these two lines:
%\usepackage{createspace}
%\usepackage[size=pocket,noicc]{createspace}
are commented out. Remove the %
symbol in front of each line. Put the %
symbol in front of the line \usepackage[...]{geometry}
.
Now your text will compile in accordance with Createspace requirements. If you don't have the package createspace.sty
, look for it on Google. In a pinch, put it in the same directory as your .tex
file; installation questions are beyond me.
Hope this helps.
Best Answer
The problem has been solved on LaTeX-Community.org.
Since the poster used square brackets for the text, LaTeX treated it like label text and aligns it this way, right aligned with few space. For demonstrating that explanation:
So the solution is to remove the square brackets. If square brackets cause such problems with
\item
or other commands, they can be protected by braces{[...]}
or separated from the command by braces{}[...]
.