方便修改的中式列表

前言

LaTeX\LaTeX 中的列表风格是西方风格,不符合我国常见的列表风格,但大多数新手由于不知道、不会、懒得去阅读 texdoc enumitem,因此可能会手写列表,在《低水平 LaTeX 作品的特点》中我们知道,手写列表是非常蠢的,因此我写了一份(低水平)代码,能让新手方便的使用中式风格的列表。

更多的请阅读 texdoc enumitem

正文

基本思路是建立一个长度 \labellengthx\labellengthx 数值为数字+符号,再让 itemindent=2\ccwd+\the\labellengthxx=i, ii, iii, iv),即可达到缩进两个 \ccwd 的效果。

四个计数器输出默认为 \chinese\arabic\alph\roman,如果要修改,改

\renewcommand\theenumi{\chinese{enumi}}
\renewcommand\theenumii{\arabic{enumii}}
\renewcommand\theenumiii{\alph{enumiii}}
\renewcommand\theenumiv{\roman{enumiv}}

即可。要注意,有时候会出现没有正确缩进两个 \ccwd 的情况,这时候要对应修改

\def\setmytheenumi#1{\def\mytheenumi{#1}\setlength{\labellengthi}{\widthof{\mytheenumi}}}
\def\setmytheenumii#1{\def\mytheenumii{#1}\setlength{\labellengthii}{\widthof{\mytheenumii}}}
\def\setmytheenumiii#1{\def\mytheenumiii{#1}\setlength{\labellengthiii}{\widthof{a\mytheenumiii}}}
\def\setmytheenumiv#1{\def\mytheenumiv{#1}\setlength{\labellengthiv}{\widthof{i\mytheenumiv}}}

\setlength{\labellengthx}{\widthof{<列表第一个符号>\mytheenumx}}

部分,如果看不懂就别改了。

使用:修改

\setmytheenumi{\theenumi、}
\setmytheenumii{\theenumii.}
\setmytheenumiii{\theenumiii.}
\setmytheenumiv{\theenumiv.}

即可。

完整代码:

\documentclass{ctexart}
\usepackage{calc,enumitem}
\newlength{\labellengthi}
\setlength{\labellengthi}{0pt}
\newlength{\labellengthii}
\setlength{\labellengthii}{0pt}
\newlength{\labellengthiii}
\setlength{\labellengthiii}{0pt}
\newlength{\labellengthiv}
\setlength{\labellengthiv}{0pt}
\setlist[enumerate,1]{leftmargin=0pt,labelsep=0pt,itemindent=2\ccwd+\the\labellengthi,parsep=0pt,itemsep=0pt,topsep=0pt,partopsep=0pt,listparindent=2\ccwd}
\setlist[enumerate,2]{leftmargin=0pt,labelsep=0pt,itemindent=2\ccwd+\the\labellengthii,parsep=0pt,itemsep=0pt,topsep=0pt,partopsep=0pt,listparindent=2\ccwd}
\setlist[enumerate,3]{leftmargin=0pt,labelsep=0pt,itemindent=2\ccwd+\the\labellengthiii,parsep=0pt,itemsep=0pt,topsep=0pt,partopsep=0pt,listparindent=2\ccwd}
\setlist[enumerate,4]{leftmargin=0pt,labelsep=0pt,itemindent=2\ccwd+\the\labellengthiv,parsep=0pt,itemsep=0pt,topsep=0pt,partopsep=0pt,listparindent=2\ccwd}

\def\setmytheenumi#1{\def\mytheenumi{#1}\setlength{\labellengthi}{\widthof{\mytheenumi}}}
\def\setmytheenumii#1{\def\mytheenumii{#1}\setlength{\labellengthii}{\widthof{\mytheenumii}}}
\def\setmytheenumiii#1{\def\mytheenumiii{#1}\setlength{\labellengthiii}{\widthof{a\mytheenumiii}}}
\def\setmytheenumiv#1{\def\mytheenumiv{#1}\setlength{\labellengthiv}{\widthof{i\mytheenumiv}}}

\def\mytheenumi{\theenumi}
\def\mytheenumii{\theenumii}
\def\mytheenumiii{\theenumiii}
\def\mytheenumiv{\theenumiv}

\renewcommand\theenumi{\chinese{enumi}}
\renewcommand\theenumii{\arabic{enumii}}
\renewcommand\theenumiii{\alph{enumiii}}
\renewcommand\theenumiv{\roman{enumiv}}

\def\labelenumi{\mytheenumi}
\setlength{\labellengthi}{\widthof{\mytheenumi}}
\def\labelenumii{\mytheenumii}
\setlength{\labellengthii}{\widthof{\mytheenumii}}
\def\labelenumiii{\mytheenumiii}
\setlength{\labellengthiii}{\widthof{\mytheenumiii}}
\def\labelenumiv{\mytheenumiv}
\setlength{\labellengthiv}{\widthof{\mytheenumiv}}

\def\test{劳仑衣普桑,认至将指点效则机,最你更枝。劳仑衣普桑,认至将指点效则机,最你更枝。劳仑衣普桑,认至将指点效则机,最你更枝。}

\setmytheenumi{\theenumi、}
\setmytheenumii{\theenumii.}
\setmytheenumiii{\theenumiii.}
\setmytheenumiv{\theenumiv.}

\begin{document}
\test
\begin{enumerate}
\item \test

\test
\begin{enumerate}
\item \test

\test
\begin{enumerate}
\item \test

\test
\begin{enumerate}
\item \test

\test
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\test
\end{document}

效果图:

更进一步的,还可以修改 itemize 环境的样式,例如:

\setlist[itemize,1]{leftmargin=0pt,labelsep=\ccwd-\widthof{\textbullet},itemindent=3\ccwd,parsep=0pt,itemsep=0pt,topsep=0pt,partopsep=0pt,listparindent=2\ccwd}
文章作者: sikouhjw
文章链接: https://sikouhjw.github.io/2020/06/04/2020-06-04-Chinese-style-list/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 sikouhjw.github.io
支付宝捐赠
微信捐赠