Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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? :)

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
    
I modify your answer slightly to fit my demand better. Thank for your time. :) –  Ch'en Meng Dec 14 '13 at 10:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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