编辑:代码片段扩展为完整的工作示例。它包含我正在使用的实际文档中使用的所有包。
我有一个自定义枚举环境设置为:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lmodern} % Font package
\usepackage{textcomp} % Package for special symbols
\usepackage[pdftex]{color, graphicx} % For pdf output and jpg/png graphics
\usepackage[pdftex, plainpages=false]{hyperref} % For hyperlinks and pdf metadata
\usepackage{fancyhdr} % For nicer page headers
\usepackage{amsmath, amssymb} % For better math
\usepackage[square,numbers]{natbib} % For bibliography
\usepackage[footnotesize,bf]{caption} % For more control over figure captions
\usepackage{blindtext}
\usepackage{titlesec}
\usepackage[titletoc]{appendix}
\usepackage{enumitem}
% enumitem list setup
\newlist{pseudocode}{enumerate}{2}% allow two levels of nesting in an enumerate-like environment
\setlist[pseudocode]{nosep}% compact spacing for all nesting levels
\setlist[pseudocode,1]{label=\arabic*.}% labels for top level
\setlist[pseudocode,2]{label=\arabic{pseudocodei}\alph*.}% labels for second level
\begin{document}
\section{Pseudocode}
\begin{pseudocode}
\item Initialization
\begin{pseudocode}
\item Initialization step \label{initStep1}
\item Another initialization step
\end{pseudocode}
\item Loop
\end{pseudocode}
\section{What does it do?}
In initialization step \ref{initStep1}, the array is...
\end{document}
最后一行输出:
在初始化步骤 1a 中,数组是......
但我想要:
在初始化步骤 1a 中,数组是......
有没有办法让 Latex 从参考文献中删除句点?
答案1
是的,enumitem
有一个ref
键,它允许您以不同于标签的方式格式化参考。
\documentclass{article}
\usepackage{enumitem}
% enumitem list setup
\newlist{pseudocode}{enumerate}{2}% allow two levels of nesting in an enumerate-like environment
\setlist[pseudocode]{nosep}% compact spacing for all nesting levels
\setlist[pseudocode,1]{label=\arabic*.,ref=\arabic*}% labels for top level
\setlist[pseudocode,2]{label=\arabic{pseudocodei}\alph*.,ref=\arabic{pseudocodei}\alph*}% labels for second level
\begin{document}
\section{Pseudocode}
\begin{pseudocode}
\item Initialization
\begin{pseudocode}
\item Initialization step \label{initStep1}
\item Another initialization step
\end{pseudocode}
\item Loop
\end{pseudocode}
\section{What does it do?}
In initialization step \ref{initStep1}, the array is...
\end{document}