包 easylist:如何将标记(如句点)从数字的右侧移动到左侧?

包 easylist:如何将标记(如句点)从数字的右侧移动到左侧?

我习惯easylist在文档中创建列表。通常我们会得到一个列表编号方案,如1.2.等等。我想将句点符号从数字的右侧移到左侧,如.1.2等等。这可以吗?

\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}

答案1

以下最小示例引入了一个PreMark插入内容的键计数器的每个级别。此外,它还允许使用特定级别的预标记:仅PreMark1在级别的预标记1、仅PreMark2在级别的预标记2等。

在此处输入图片描述

\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}

答案2

是的,这是可能的,但需要付出一些代价,因为包的代码在编写时并没有考虑到这种扩展的灵活性。(不过,我不会责怪包的作者,因为我也很难想象在数字前而不是数字后使用标记的情况。)

这是修改后的代码。您必须直接在命令后复制\usepackage{xpatch}和之间的代码块\makeatother(包括这些行)\usepackage{easylist}

\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}

在此处输入图片描述

相关内容