如何将枚举项标签中的零更改为点零?

如何将枚举项标签中的零更改为点零?

平均能量损失

\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{enumitem}

\makeatletter
 \protected\def\pmzerodot{%
  \nfss@text{%
\sbox0{$\vcenter{}$}% math axis
\sbox2{0}%
\sbox4{0\/}%
\ooalign{%
  0\cr
  \hidewidth
  \kern\dimexpr\wd4-\wd2\relax % compensate for slanted fonts
  \raise\dimexpr(\ht2-\dp2)/2-\ht0\relax\hbox{%
    \if b\expandafter\@car\f@series\@nil\relax
      \mathversion{bold}%
    \fi
    $\cdot\m@th$%
  }%
  \hidewidth
  \cr
  \vphantom{0}% correct depth of final symbol
}%
  }%
}

\newcommand*{\dotarabic}[1]{%
  \expandafter\@dotarabic\csname c@#1\endcsname
}
\newcommand*{\@dotarabic}[1]{%
  \expandafter\dotarabic@scan\number #1\relax
}
\newcommand*{\dotarabic@scan}[1]{%
  \ifx\relax#1%
    \expandafter\@gobble
  \else
\expandafter\@firstofone
  \fi
  {%
    \ifnum#1=0 %
  \ifincsname
    0%
  \else
    \pmzerodot
  \fi
\else
  #1%
\fi
\dotarabic@scan
  }%
}
\makeatother

\renewcommand*{\theequation}{\dotarabic{chapter}.\dotarabic{equation}}
\renewcommand*{\thepage}{\dotarabic{page}}
\renewcommand*{\thechapter}{\dotarabic{chapter}}
\renewcommand*{\thesection}{\dotarabic{chapter}.\dotarabic{section}}
\renewcommand*{\thetable}{\dotarabic{chapter}.\dotarabic{table}}
\renewcommand*{\thefigure}{\dotarabic{chapter}.\dotarabic{figure}}
%\renewcommand*{\labelenumi}{\dotarabic{enumi}} <- Don't working
%\renewcommand*{\theenumi}{\dotarabic{enumi}} <- Don't working

\begin{document} 

\begin{enumerate}
\item One
\item Two
\item Three
\item Four
\item Five
\item Six
\item Seven
\item Eight
\item Nine
\item Ten
\end{enumerate}

\end{document}

我无法运行\item Ten。我添加了\renewcommand*{\labelenumi}{\dotarabic{enumi}}\renewcommand*{\theenumi}{\dotarabic{enumi}},但没有用。我将我尝试执行的操作标记为红色。

在此处输入图片描述

我不知道该怎么办。我等待你的帮助。

感谢@Heiko Oberdiek:https://tex.stackexchange.com/a/240271/33075

答案1

没有enumitem你需要:

\renewcommand*{\labelenumi}{\theenumi.}
\renewcommand*{\theenumi}{\dotarabic{enumi}}

在此处输入图片描述

\documentclass{article}

\makeatletter
 \protected\def\pmzerodot{%
  \nfss@text{%
\sbox0{$\vcenter{}$}% math axis
\sbox2{0}%
\sbox4{0\/}%
\ooalign{%
  0\cr
  \hidewidth
  \kern\dimexpr\wd4-\wd2\relax % compensate for slanted fonts
  \raise\dimexpr(\ht2-\dp2)/2-\ht0\relax\hbox{%
    \if b\expandafter\@car\f@series\@nil\relax
      \mathversion{bold}%
    \fi
    $\cdot\m@th$%
  }%
  \hidewidth
  \cr
  \vphantom{0}% correct depth of final symbol
}%
  }%
}

\newcommand*{\dotarabic}[1]{%
  \expandafter\@dotarabic\csname c@#1\endcsname
}
\newcommand*{\@dotarabic}[1]{%
  \expandafter\dotarabic@scan\number #1\relax
}
\newcommand*{\dotarabic@scan}[1]{%
  \ifx\relax#1%
    \expandafter\@gobble
  \else
\expandafter\@firstofone
  \fi
  {%
    \ifnum#1=0 %
  \ifincsname
    0%
  \else
    \pmzerodot
  \fi
\else
  #1%
\fi
\dotarabic@scan
  }%
}
\makeatother

\renewcommand*{\labelenumi}{\theenumi.}
\renewcommand*{\theenumi}{\dotarabic{enumi}}

\begin{document}

\begin{enumerate}
  \item One
  \item Two
  \item Three
  \item Four
  \item Five
  \item Six
  \item Seven
  \item Eight
  \item Nine
  \item Ten
\end{enumerate}

\end{document}

enumitem需要:

\usepackage{enumitem}
\makeatletter
\AddEnumerateCounter\dotarabic\@dotarabic{0}
\makeatother

使用来\AddEnumerateCounter添加计数器以便在列表的可选参数中使用。

\documentclass{article}

\makeatletter
 \protected\def\pmzerodot{%
  \nfss@text{%
\sbox0{$\vcenter{}$}% math axis
\sbox2{0}%
\sbox4{0\/}%
\ooalign{%
  0\cr
  \hidewidth
  \kern\dimexpr\wd4-\wd2\relax % compensate for slanted fonts
  \raise\dimexpr(\ht2-\dp2)/2-\ht0\relax\hbox{%
    \if b\expandafter\@car\f@series\@nil\relax
      \mathversion{bold}%
    \fi
    $\cdot\m@th$%
  }%
  \hidewidth
  \cr
  \vphantom{0}% correct depth of final symbol
}%
  }%
}

\newcommand*{\dotarabic}[1]{%
  \expandafter\@dotarabic\csname c@#1\endcsname
}
\newcommand*{\@dotarabic}[1]{%
  \expandafter\dotarabic@scan\number #1\relax
}
\newcommand*{\dotarabic@scan}[1]{%
  \ifx\relax#1%
    \expandafter\@gobble
  \else
\expandafter\@firstofone
  \fi
  {%
    \ifnum#1=0 %
  \ifincsname
    0%
  \else
    \pmzerodot
  \fi
\else
  #1%
\fi
\dotarabic@scan
  }%
}
\makeatother

\usepackage{enumitem}

\makeatletter
\AddEnumerateCounter\dotarabic\@dotarabic{0}
\makeatother

\begin{document}

\begin{enumerate}[label = \dotarabic*., ref = \dotarabic*]
  \item One
  \item Two
  \item Three
  \item Four
  \item Five
  \item Six
  \item Seven
  \item Eight
  \item Nine
  \item Ten
\end{enumerate}

\end{document}

相关内容