![包 easylist:如何将标记(如句点)从数字的右侧移动到左侧?](https://linux22.com/image/341013/%E5%8C%85%20easylist%EF%BC%9A%E5%A6%82%E4%BD%95%E5%B0%86%E6%A0%87%E8%AE%B0%EF%BC%88%E5%A6%82%E5%8F%A5%E7%82%B9%EF%BC%89%E4%BB%8E%E6%95%B0%E5%AD%97%E7%9A%84%E5%8F%B3%E4%BE%A7%E7%A7%BB%E5%8A%A8%E5%88%B0%E5%B7%A6%E4%BE%A7%EF%BC%9F.png)
我习惯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}