2

I'm new to LaTex and I want to use compactenum from the paralist package for an enumeration. So I wrote the following:

\documentclass{article}
\usepackage{paralist}

\begin{document}
\begin{compactenum}[\mbox{FA-SWK-}1]
  \item Item one
  \item Item two
  \item Item three
  \item Item four
  \item Item five
  \item Item six
  \item Item seven
  \item Item eight
  \item Item nine
  \item Item ten
  \item Item eleven
  % and so on...
\end{compactenum}
\end{document}

Now I have the problem that the text from item 10 is out of alignment. Actually it looks like that:

FA-SWK-1 Item one
FA-SWK-2 Item two
...
FA-SWK-10 Item ten

But I want that it looks like this:

FA-SWK-1  Item one
FA-SWK-2  Item two
...
FA-SWK-10 Item ten

It is possible to add a null only for the first nine items or to change the spacing between the enumeration and the text?

  • Welcome to TeX.SX! Is compactenum the name of a package? Or is it a special enumerate list made with enumitem? – user31729 Sep 18 '15 at 9:53
  • 1
    Welcome to TeX - LaTeX! Are you using the paralist package. Please add a minimal working example (MWE) – Andrew Swann Sep 18 '15 at 9:58
  • compactenum is an environment from the paralist package – riede Sep 18 '15 at 10:42
3

You can trick paralist into leaving more space for the number:

\documentclass{article}
\usepackage{paralist}

\protected\def\double#1\double{\makebox[1em][l]{#1}}

\begin{document}

\begin{compactenum}[\mbox{FA-SWK-}\double1\double]
  \item Item one
  \item Item two
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
\end{compactenum}

\end{document}

With enumitem:

\documentclass{article}
\usepackage{enumitem}

\newcommand{\boxedarabic}[1]{\makebox[1em][l]{\arabic#1}}

\begin{document}

\begin{enumerate}[label=FA-SWK-\boxedarabic*,nosep]
  \item Item one
  \item Item two
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
\end{enumerate}

\end{document}

enter image description here

| improve this answer | |
  • I'm not sure if this is the nicest method to resove my problem, but it works! I used your first solution with paralist – riede Sep 18 '15 at 10:31
  • @riede The important thing is avoiding 1 being between braces. The trick above does it. – egreg Sep 18 '15 at 10:34
  • Personally I find the left alignment of the numbers 'weird', but any of the solutions (and the O.P.) have this feature – user31729 Sep 18 '15 at 12:13
4

A variant with enumitem, using the widest key:

\documentclass{article}
\usepackage{enumitem}
\newlength\mylabelwd
\settowidth{\mylabelwd}{FA-SWK-999}

\begin{document}

Some text some text some text some text some text some text some text some text some text some text some text.
\begin{enumerate}[label=FA-SWK-\arabic*, widest =999, align=left, labelindent=\parindent, leftmargin=\dimexpr\mylabelwd+\labelindent+\labelsep\relax, itemindent=*, noitemsep]
  \item Item one
  \item Item two
  \item Item three and so on. Item three and so on. Item three and so on. Item three and so on.
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
  \item Item three and so on
\end{enumerate}

\end{document}

enter image description here

| improve this answer | |
  • Thank you for your answer. This solution works for me when each item has only one row. Once there is a seconds row it doesn't work. The second row starts on the left side of the page and isn't arranged to the first row. – riede Sep 18 '15 at 11:01
  • You didn't say in your post there are multilined items. I'll fix that in a moment. – Bernard Sep 18 '15 at 11:05
  • @riede: I've modified my code. Is that what you want? – Bernard Sep 18 '15 at 12:04
2

You can use \phantom to create a character:

\begin{compactenum}[\text{FA-SWK-}1]
  \item \leavevmode\hphantom{0}one 
  \item \leavevmode\hphantom{0}two 
  \item \leavevmode\hphantom{0}three and so on 
  % Some other \item
  \item FA-SWK-10 ten
\end{compactenum}

It creates an invisible character that take the size of a as space. (can't show you the result due to the computer I use)

| improve this answer | |
  • @ChristianHupfer wrong copy-paste thank you ;-) – Romain Picot Sep 18 '15 at 9:56
  • 1
    \leavevmode\hphantom{0} would be much better than \phantom{a}, for the simple reason that it works. Not because of 0 instead of a, but because \phantom{...} doesn't start a paragraph. And you shouldn't have FA-SWK-1 and so on in the items. – egreg Sep 18 '15 at 10:17
  • Thank you for your answer. This solution doen't really work for me. It looks like the invisible character will be added to the line before. But I don't know why. – riede Sep 18 '15 at 10:45
  • \leavevmode\hphantom{0} works for the first row. Once the item has more than one row this solution doesn't help me because the second row has the old spacing. – riede Sep 18 '15 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.