![在新环境中自定义参考](https://linux22.com/image/436582/%E5%9C%A8%E6%96%B0%E7%8E%AF%E5%A2%83%E4%B8%AD%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%82%E8%80%83.png)
我的一位计算机科学教授让我们使用他的模板来撰写软件工程硕士论文。
当我使用 \ref{...} 时,它只显示数字,这是一个问题,因为我有多个子系统,每个子系统都有自己的列表(例如,一个是 SGPA1,另一个是 SGU1)。我一直在尝试使用这个问题来更改它(\ref 应使用枚举标签名称),但并没有起到作用。
有什么解决办法吗,当我使用 \ref{环境项目} 它还显示字符(本例中为 SGPA)?
\newenvironment{functionalProcesosAutomaticos}
{
\bgroup
\renewcommand\baselinestretch{1.3}
\typeout{Begining enumeration}
\ifnum
\@enumdepth >3 \@toodeep
\else
\advance\@enumdepth \@ne
\def\@enumctr{enum\romannumeral\the\@enumdepth}
\list{\csname label\@enumctr\endcsname}
{
\small
\partopsep=0\myem
\topsep=\@listinterlined
\itemsep=\@listinterlined
\parsep=\@listinterlined
\advance\topsep by .3\myem
\advance\itemsep by .15\myem
\itemindent=0\myem
\rightmargin=5\myex
\leftmargin=8\myex
\labelsep=1\myex \labelwidth=3\myex
\usecounter{\@enumctr}
\renewcommand*{\labelenumi}{\textbf{SGPA\theenumi}}
\renewcommand*{\theenumii}{\arabic{enumii}}
\renewcommand*{\labelenumii}{\textbf{SGPA\theenumi.\theenumii.--}}
\renewcommand*{\theenumiii}{\arabic{enumiii}}
\renewcommand*{\labelenumiii}{\textbf{SGPA\theenumi.\theenumii.\theenumiii.--}}
}
\fi
}
{
\endlist
\typeout{Ending enumeration}
\egroup
}
答案1
您调整了
\theenumi
、\theenumii
和\theenumiii
、
\labelenumi
、\labelenumii
。\labelenumiii
我认为您还需要调整
\p@enumi
,,\p@enumii
。\p@enumiii
这些宏在存储由宏使用的交叉引用数据时提供前缀/后缀。\the⟨counter⟩
\refstepcounter
\label
\@currentlabel
我不知道\myem
、\myex
和\@listinterlined
是什么,但我认为它们是一些单位/长度,并且我自己定义了它们,具有奇怪的值。;-)
该示例是否提供了您想要的输出?
\errorcontextlines=10000
\documentclass{article}
%\usepackage{hyperref}
\makeatletter
\def\myem{em}
\def\myex{ex}
\def\@listinterlined{.5\baselineskip}
\newenvironment{functionalProcesosAutomaticos}
{%%%%
\bgroup
\renewcommand\baselinestretch{1.3}%%%%%%%%%%%%
\typeout{Begining enumeration}%%%%%%%%%%%%
\advance\@enumdepth \@ne
\ifnum
\@enumdepth >4 \@toodeep
\else
\def\@enumctr{enum\romannumeral\the\@enumdepth}%%%%
\list{\csname label\@enumctr\endcsname}%%%%
{%%%%
\small
\partopsep=0\myem\relax
\topsep=\@listinterlined\relax
\itemsep=\@listinterlined\relax
\parsep=\@listinterlined\relax
\advance\topsep by .3\myem\relax
\advance\itemsep by .15\myem\relax
\itemindent=0\myem\relax
\rightmargin=5\myex\relax
\leftmargin=8\myex\relax
\labelsep=1\myex\relax
\labelwidth=3\myex\relax
\usecounter{\@enumctr}%
\renewcommand*{\theenumi}{SGPA\arabic{enumi}}%%%%
\renewcommand*{\theenumii}{\theenumi.\arabic{enumii}}%%%%
\renewcommand*{\theenumiii}{\theenumii.\arabic{enumiii}}%%%%
\renewcommand*{\theenumiv}{\theenumiii.\arabic{enumiv}}%%%%
\renewcommand*{\p@enumi}{}%%%%
\renewcommand*{\p@enumii}{}%%%%
\renewcommand*{\p@enumiii}{}%%%%
\renewcommand*{\p@enumiv}{}%%%%
% \renewcommand*{\p@enumii}[1]{##1.--}%%%%
% \renewcommand*{\p@enumiii}[1]{##1.--}%%%%
% \renewcommand*{\p@enumiv}[1]{##1.--}%%%%
\renewcommand*{\labelenumi}{\textbf{\theenumi}}%%%%
\renewcommand*{\labelenumii}{\textbf{\theenumii}}%%%%
\renewcommand*{\labelenumiii}{\textbf{\theenumiii}}%%%%
\renewcommand*{\labelenumiv}{\textbf{\theenumiv}}%%%%
% \renewcommand*{\labelenumii}{\textbf{\theenumii.--}}%%%%
% \renewcommand*{\labelenumiii}{\textbf{\theenumiii.--}}%%%%
% \renewcommand*{\labelenumiv}{\textbf{\theenumiv.--}}%%%%
}%%%%
\fi
}{%%%%
\ifnum
\@enumdepth >4
\else
\expandafter\endlist
\fi
\typeout{Ending enumeration}%%%%
\egroup
}
\makeatother
\begin{document}
\ref{AnotherItem}
\ref{AnotherNestedItem}
\ref{AnotherNestedNestedItem}
\ref{AnotherNestedNestedNestedItem}
\begin{functionalProcesosAutomaticos}
\item An item
\item\label{AnotherItem} Another item
\item Yet another item
\begin{functionalProcesosAutomaticos}
\item A nested item
\item\label{AnotherNestedItem} Another nested item
\item Yet another nested item
\begin{functionalProcesosAutomaticos}
\item A nested nested item
\item\label{AnotherNestedNestedItem} Another nested nested item
\item Yet another nested nested item
\begin{functionalProcesosAutomaticos}
\item A nested nested nested item
\item\label{AnotherNestedNestedNestedItem} Another nested nested nested item
\item Yet another nested nested nested item
%\begin{functionalProcesosAutomaticos}
%\item A nested nested nested nested item
%\item\label{AnotherNestedNestedNestedNestedItem} Another nested nested nested nested item
%\item Yet another nested nested nested nested item
%\end{functionalProcesosAutomaticos}
\end{functionalProcesosAutomaticos}
\end{functionalProcesosAutomaticos}
\end{functionalProcesosAutomaticos}
\end{functionalProcesosAutomaticos}
\end{document}