轻松列表;创建新风格

轻松列表;创建新风格

宏的创建者Easylist是@ereg (Easylist 里面的 adjustwidth

我的 MWE:

\documentclass{article}
\usepackage{amssymb}
\usepackage[ampersand]{easylist}
\usepackage{changepage}
\usepackage{lipsum}

\makeatletter
\newbox\Easylist@box
\newenvironment{Easylist}
{\par\xdef\Easylist@tpd{\the\prevdepth}%
\setbox\Easylist@box=\vbox\bgroup
\dimen@=\@totalleftmargin
\@parboxrestore
\leftskip=\dimen@
\prevdepth\Easylist@tpd
\begin{easylist}}
{\end{easylist}\xdef\Easylist@tpd{\the\prevdepth}\egroup
\unvbox\Easylist@box\par\prevdepth\Easylist@tpd}
\makeatother

\usepackage{amssymb}
\usepackage[ampersand]{easylist}
\ListProperties(Hide=100,Hang=true,FinalSpace=0.5cm,Align=fixed,
Margin1=0.5cm,Margin2=1.5cm,Margin3=2.5cm,Margin4=3.5cm,
Margin5=4.5cm,Margin6=5.5cm,Margin7=6.5cm,Space=0.15cm,Space*=0.15cm,
Style1*=\textbullet\hspace{0.25cm},%
Style2*=$\circ$\hspace{0.25cm},%
Style3*=\tiny$\blacksquare$\hspace{0.25cm},%
Style4*=\tiny$\square$\hspace{0.25cm})

\begin{document}
\begin{adjustwidth}{2cm}{}
    \begin{Easylist}
        & First thingy
        && Second thingy
        &&& Third thingy
        &&&& Fourth thingy
    \end{Easylist}
\end{adjustwidth}
\end{document}

我在文档中找到了easylist命令使用的预定义样式\begin{easylist}[<Style>。因此,据我所知,可以创建多种样式并轻松地从一种样式更改为另一种样式。我对创建两种新样式感兴趣,这样我就可以轻松地从一种样式切换到另一种样式。您能给我举个例子,说明如何创建如图所示的新样式吗?非常感谢!:)

现在我正在使用命令,\ListProperties但是当我想更改文档内部的样式时非常困难。

在此处输入图片描述

答案1

我无法从文档中找到一种轻松定义自己的样式的方法,但你可以采用以下解决方案定义自定义命名的 easylist 样式定义您的自定义样式。下面我定义了四种样式:

\definemyeasylist{lowercasestyle}{Numbers=l}
\definemyeasylist{uppercasestyle}{Numbers=L}
\definemyeasylist{romanlowercasestyle}{Numbers=R}
\definemyeasylist{romanuppercasestyle}{Numbers=R}

得出的结果是:

在此处输入图片描述

代码:

\documentclass{article}
\usepackage[ampersand]{easylist}
\usepackage{xcolor}

%% https://tex.stackexchange.com/a/375832/4301
\def\definemyeasylist#1#2{\expandafter\def\csname myeasylist@style@#1\endcsname{\NewList(#2)}}
\def\myeasylist{\futurelet\next\domyeasylist}
\def\domyeasylist{\ifx[\next\expandafter\domyeasylistone\else\expandafter\domyeasylistnop\fi}
\def\domyeasylistone[#1]{\begin{easylist}\if\relax\detokenize{#1}\relax\else\csname myeasylist@style@#1\endcsname\fi}
\def\domyeasylistnop{\begin{easylist}\NewList}
\def\endmyeasylist{\end{easylist}}

\definemyeasylist{lowercasestyle}{Numbers=l}
\definemyeasylist{uppercasestyle}{Numbers=L}
\definemyeasylist{romanlowercasestyle}{Numbers=r}
\definemyeasylist{romanuppercasestyle}{Numbers=R}


\begin{document}
\begin{minipage}{0.3\linewidth}
    \begin{myeasylist}[enumerate]
        & dog
        & cat
        & rabbit
    \end{myeasylist}
    \par\medskip
    \begin{myeasylist}[lowercasestyle]
        & dog
        & cat
        & rabbit
    \end{myeasylist}
\end{minipage}%
\begin{minipage}{0.3\linewidth}
    \begin{myeasylist}[romanuppercasestyle]
        & dog
        & cat
        & rabbit
    \end{myeasylist}
    \par\medskip
    \begin{myeasylist}[romanlowercasestyle]
        & dog
        & cat
        & rabbit
    \end{myeasylist}
\end{minipage}%
\end{document}

相关内容