0

I created a custom reference but I want to use cross-referencing to refer to the custom reference. When I want to reference it I want it to show F/R 1, F/R 1.1 or F/R 1.1.1 when I cross reference the custom counter. How can I do this?

    \newcounter{thephase} \setcounter{thephase}{0}
\newcounter{thesubphase}[thephase] \setcounter{thesubphase}{0}
\newcounter{thesubsubphase}[thesubphase] \setcounter{thesubsubphase}{0}
\newcommand{\phase}[1]{\refstepcounter{thephase}\textbf{F/R \arabic{thephase}}}
\newcommand{\subphase}[1]{\refstepcounter{thesubphase}\textbf{F/R \arabic{thephase}.\arabic{thesubphase}}%
    }
\newcommand{\subsubphase}[1]{\refstepcounter{thesubsubphase}\textbf{F/R \arabic{thephase}.\arabic{thesubphase}.\arabic{thesubsubphase}}%
}

1 Answer 1

1

An example of my interpretation of the question:

\documentclass{article}

\newcounter{phase}
\renewcommand*{\thephase}{F/R~\arabic{phase}}

\newcounter{subphase}[phase]
\renewcommand*{\thesubphase}{\thephase.\arabic{subphase}}

\newcounter{subsubphase}[subphase]
\renewcommand*{\thesubsubphase}{\thesubphase.\arabic{subphase}}

\newcommand*{\phase}[1]{%
  \leavevmode
  \refstepcounter{phase}%
  \label{#1}%
  \textbf{\thephase}%
}
\newcommand*{\subphase}[1]{%
  \leavevmode
  \refstepcounter{subphase}%
  \label{#1}%
  \textbf{\thesubphase}%
}
\newcommand*{\subsubphase}[1]{%
  \leavevmode
  \refstepcounter{subsubphase}%
  \label{#1}%
  \textbf{\thesubsubphase}%
}

\begin{document}

  \phase{A} First phase.

  \subphase{B} First subphase.

  \subsubphase{C} First subsubphase.

  References:
  \ref{A}, \ref{B}, \ref{C}

\end{document}

Result:

F/R 1 First phase.
F/R 1.1 First subphase.
F/R 1.1.1 First subsubphase.
References: F/R 1, F/R 1.1, F/R 1.1.1

Remarks:

  • I have simplified the counter names, they are using a different namespace as macros, thus counter phase and \phase are different entities.

  • The counter have a accompanying macro \the<counter> that is used for the display of the counter value und its references.

  • The definitions for the counter displays of \thesubphase and \thesubsubphase are simplified by using the parent counters.

  • \leavevmode ensures that the paragraph has started to avoid that \refstepcounter moves to vertical mode on a previous page than the text set by \textbf.

  • The argument of the macros is not used in the question. Maybe, it is intended for the cross-referencing label name, see the example file.

  • The cross-referencing works as usual with \label (already present in the \phase macros) and \ref and \pageref.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .