5

I need two styles in my document: one for most equations, using the default style of equation-number; the other one for the left ones whose amount will not be lager than 10, using a new style (shown as follow).

Function 1

Here Function should be upright (not italic).

In terms of the reference style (when using \ref{} command), both of these two styles are the same, just as the default does. For example, if we have two equations, and they both are numbered as 1 ((1) and Function 1), they should be referenced as 1 in document text.

I've tried \newtagform and \usetagform provided by the package mathtools, and get the right output for equation numbers. However, there are two disadvantages:

  • The ref-numbers do not work well;
  • I need to justify the numbers for those equations who has the special number style, which is boring.

My code goes here:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsmath}

\newtagform{fnc}{Function~}{}
\begin{document}
\begin{equation}\label{eqn:ori1}
    E=mc^2
\end{equation}
\begin{equation}\label{eqn:tag1}
    \setcounter{equation}{1}
    \usetagform{fnc}
    E=mc^2
\end{equation}
\begin{equation}\label{eqn:ori2}
    E=mc^2
\end{equation}
\begin{equation}\label{eqn:tag2}
    \setcounter{equation}{2}
    \usetagform{fnc}
    E=mc^2
\end{equation}

Ref test

\ref{eqn:ori1}, \ref{eqn:ori2}, \ref{eqn:tag1}, \ref{eqn:tag2}.
\end{document}

And its output:

enter image description here

I need these two series of style do work well simultaneously (the numbering part and also the referencing part). Does any one here has clues or hints? :)

1 Answer 1

6

I suggest to define a new equation environment with it's own counter:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsmath}
\newtagform{fnc}{Function~}{}
\makeatletter
\@definecounter{Fequation}
\def\theFequation{\arabic{Fequation}}
\def\incr@Feqnum{\refstepcounter{Fequation}\let\incr@Feqnum\@empty}
\newenvironment{Fequation}{%
  \incr@Feqnum
  \mathdisplay@push
  \st@rredfalse \global\@eqnswtrue
  \mathdisplay{equation}%
  \def\theequation{\theFequation}%
  \usetagform{fnc}%
}{%
  \endmathdisplay{equation}%
  \mathdisplay@pop
  \ignorespacesafterend
}
\makeatother

\begin{document}
\begin{equation}\label{eqn:ori1}
    E=mc^2
\end{equation}
\begin{Fequation}\label{eqn:tag1}
    E=mc^2
\end{Fequation}
\begin{equation}\label{eqn:ori2}
    E=mc^2
\end{equation}
\begin{Fequation}\label{eqn:tag2}
    E=mc^2
\end{Fequation}

Ref test

\ref{eqn:ori1}, \ref{eqn:ori2}, \ref{eqn:tag1}, \ref{eqn:tag2}.
\end{document}

enter image description here


Edit

I'm the OP.

Since I do not want the brackets around Function #, a slight modification was adapted into this answer.

1
  • I modify your answer slightly to fit my demand better. Thank for your time. :)
    – Ch'en Meng
    Commented Dec 14, 2013 at 10:18

You must log in to answer this question.

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