2

Suppose I have the following document,

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{align} f_{n} + f_{n-1} = f_{n-2} \label{eq:f} \end{align}
\end{document}

The {align} environment produces an equation with the label "(1)". However, I want there to be a subscript "n" after the "(1)". Moreover, I want the numbering of this equation to be automatic, i.e. if I add another equation before eq:f then eq:f would be labelled "(2)" with subscript "n" etc.

In addition, when I refer to eq:f I want to be able to use any number in the subscript, i.e. not just "n" but perhaps "4" or "n+2" instead.

Many thanks and apologies for any formatting mistakes, I am new to the TeX forum.

1 Answer 1

2

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\makeatletter
\def\maketag@@@#1{\hbox{\m@th\normalfont#1$^{\nlab}$}}
\makeatother
\DeclareRobustCommand\nlab{n}
\begin{document}


aaa
\begin{align} f_{n} + f_{n-1} = f_{n-2} \label{eq:f} \end{align}

aaa
\begin{align} f_{n} + f_{n-1} = f_{n-2} \label{eq:ff} \end{align}

see \eqref{eq:f}  or its special case {\renewcommand\nlab{4}\eqref{eq:f}}.

\end{document}

or if you just want a one-off equation

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}

\DeclareRobustCommand\nlab{n}
\begin{document}


bbb\begin{equation}0=1\end{equation}
aaa
\refstepcounter{equation}
\begin{align} f_{n} + f_{n-1} = f_{n-2} \label{eq:f} \tag*{(\theequation)$^{\nlab}$} \end{align}

aaa
\begin{align} f_{n} + f_{n-1} = f_{n-2} \label{eq:ff} `w\end{align}

see \ref{eq:f}  or its special case {\renewcommand\nlab{4}\ref{eq:f}}.

\end{document}
7
  • except that the op asked for "subscript". Mar 11, 2017 at 16:54
  • Lovely, I'm sure I can change the ^ to _ to make it subscript :-) thank you.
    – analytic
    Mar 11, 2017 at 16:56
  • @barbarabeeton this is the special delux super script edition. Mar 11, 2017 at 16:56
  • Sorry David, I've realised that this makes all equations labelled with superscript "n" however I want only equation eq:f to be labelled with superscript "n" (while eq:f is still enumerated to fit in with the other equations), is there a small change to your code that could make this happen? Thanks again.
    – analytic
    Mar 11, 2017 at 17:11
  • @analytic you can put \begingroup\makeatletter \def\maketag@@@#1{\hbox{\m@th\normalfont#1$^{\nlab}$}} before the equation and \endgroup after, of in that case simpler don't define that at all. I'll add something to the answer Mar 11, 2017 at 17:29

You must log in to answer this question.

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