3

I use easylist to create lists in a document. Normally we get a list numbering scheme like 1. and 2. etc. I would like to move the period symbol from the right of the number to the left like .1 and .2 and so on. Is this possible?

\documentclass{article}
\usepackage[ampersand]{easylist}
\begin{document}
\begin{easylist}
& First item
&& First sub of first
&& Second sub of first
& Second item
&& First sub of second
&& Second sub of second
& Third item
&& First sub of third
&& Second sub of third
\end{easylist}
\end{document}
2

The following minimal example introduces a PreMark key that inserts content before each level of the counter. Additionally it allows for the use of level-specific pre-marks: PreMark1 for a pre-mark at level 1 only, PreMark2 for a pre-mark at level 2 only, etc.

enter image description here

\documentclass{article}

\usepackage[ampersand]{easylist}
\usepackage{regexpatch}
\makeatletter
% Update \el@PrintCounters using a global search-and-replace
\xpatchcmd*{\el@PrintCounters}% <cmd>
  {\el@ItemCounter\bgroup}% <search>
  {\el@ItemCounter\csname PreMark\the\el@ControlCounter\endcsname\bgroup}% <replace>
  {}{}% <success><failure>
\el@GenericDef{PreMark}{.}% Generic pre-mark
\makeatother
\begin{document}

\begin{easylist}
  \ListProperties(Mark={})% Remove post-mark
  & First item
  && First sub of first
  && Second sub of first
  & Second item
  && First sub of second
  && Second sub of second
  & Third item
  && First sub of third
  && Second sub of third
\end{easylist}

\end{document}
  • Yes! This works thank you! However when I typed PreMark1=. and PreMark2=. into the arguments for easylist, it did not work. Instead, it looked like .1 PreMark1=. Start of paragraph... – Prevost Sep 16 '16 at 18:39
  • @Prevost: I can't replicate your problem. Here is an example of what I tried that worked. – Werner Sep 16 '16 at 18:42
  • That now works for me. Not sure what I was doing wrong, I think I didn't have the Mark={} argument in the easylist aruments. Thanks again! – Prevost Sep 16 '16 at 18:45
  • @Prevost: Yes, Mark is set after every number. Since you want a . before every number, you need to clear the Mark={} and just set PreMark=. (which would be the default in my example). – Werner Sep 16 '16 at 18:46
4

Yes, it is possible, but at some expense, since the code of the package is not written with such extended flexibility in mind. (I wouldn't blame the author of the package, though, since I also have difficulties to imagine use cases with the marker before the number instead of following it.)

Here is the modified code. You have to copy the code block between \usepackage{xpatch} and \makeatother (including these lines) directly after the \usepackage{easylist} command.

\documentclass{article}
\usepackage[ampersand]{easylist}
\usepackage{xpatch}
\makeatletter
\xpatchcmd
  {\el@PrintCounters}%
  {\xdef\el@ItemCounter{\el@ItemCounter
   \bgroup
   \csname el@NumberDenotation:\csname Numbers\the\el@ControlCounter\endcsname\endcsname{List\the\el@ControlCounter}%
   \egroup
   \csname Mark\the\el@ControlCounter\endcsname}%
  }%
  {\xdef\el@ItemCounter{\el@ItemCounter
   \csname Mark\the\el@ControlCounter\endcsname
   \bgroup
   \csname el@NumberDenotation:\csname Numbers\the\el@ControlCounter\endcsname\endcsname{List\the\el@ControlCounter}%
   \egroup}%
  }{}{}
\xpatchcmd
  {\el@PrintCounters}%
  {\xdef\el@ItemCounter{\el@ItemCounter
   \bgroup
   \csname el@NumberDenotation:\csname Numbers\the\el@ControlCounter\endcsname\endcsname{List\the\el@ControlCounter}%
   \egroup
   \expandafter\ifx\csname FinalMark\the\el@ControlCounter\endcsname\el@NA
     \csname Mark\the\el@ControlCounter\endcsname
   \else
     \csname FinalMark\the\el@ControlCounter\endcsname
   \fi}%
  }%
  {\xdef\el@ItemCounter{\el@ItemCounter
   \expandafter\ifx\csname FinalMark\the\el@ControlCounter\endcsname\el@NA
     \csname Mark\the\el@ControlCounter\endcsname
   \else
     \csname FinalMark\the\el@ControlCounter\endcsname
   \fi
   \bgroup
   \csname el@NumberDenotation:\csname Numbers\the\el@ControlCounter\endcsname\endcsname{List\the\el@ControlCounter}%
   \egroup}%
  }{}{}
\makeatother
\begin{document}
\begin{easylist}
& First item
&& First sub of first
&& Second sub of first
& Second item
&& First sub of second
&& Second sub of second
& Third item
&& First sub of third
&& Second sub of third
\end{easylist}
\end{document}

enter image description here

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.