0

One of my professors in CS have made us use his template to write our master thesis in Software Engineering.

When I use \ref{...} it only appears the number, which is a problem because I have multiple subsystems and each one has their own list (eg. one is SGPA1 and other is SGU1). I've been trying to change it using this question (\ref should use enumerate label name), and it hasn't worked.

Is there any solution so when I use \ref{an item of the environment} it also shows the characters (SGPA in this example)?

\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 Answer 1

0

You adjusted
\theenumi, \theenumii, \theenumiii
and
\labelenumi, \labelenumii, \labelenumiii.

I think you need to also adjust
\p@enumi, \p@enumii, \p@enumiii.

These macros deliver prefix/postfix to \the⟨counter⟩ when \refstepcounter stores cross-referencing-data used by \label as macro \@currentlabel.

I don't know what \myem, \myex and \@listinterlined are, but I assume they are some units/lengths and I defined them on my own, with weird values. ;-)

Does the example deliver the output you desire?

\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}

enter image description here

5
  • \def\listinterlined#1{\def\@listinterlined{#1}} \listinterlined{0.1\myem} is the list interlined, and yes, it is what I'm looking for but it doesn't work in my template :/ It doesn't compile the document, so I think at this point is a template issue, thank you anyway Jul 13, 2021 at 17:56
  • I honestly can't. The template is an absolute mess and when I tried to copy paste your code it just explode. It says No PDF, something went wrong , and no matter how many times I try to recompile it's always the same. Thank you so much for your effort, I really appreciate it :-) Jul 13, 2021 at 20:15
  • My bad!! I have just tried it again and it worked!!! I may have copied it wrongly or something. Thank you so so much Jul 13, 2021 at 20:24
  • You're the best, I swear this was driving me insane Jul 13, 2021 at 20:37
  • @SugarG.García I know these situations: Time pressure, you want to get the job done, and then you find yourself spending hours trying to trace what's going wrong... In between, you get bile up, because you actually have something better to do... :-) Jul 13, 2021 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.