6

I want to write the different but similar equations in one line, just like the picture shows, I know maybe the \tag command can work, but I have no idea on how to make the numbering automatic. enter image description here

1

1 Answer 1

1

I am not sure how rich your original code are, however with the following minimal example, you can generate the equation numbers as required.

Note: Here, I have defined and used \seteqn{<no. of eqn numbers>} and \reseteqn.

\seteqn{2} This command will print two equation numbers, and likewise if you want 4 equation numbers, then \seteqn{4} will do the job. This may be given just above the equation.

\reseteqn This may be used to reset the equation number format to the default.

\documentclass{article}

%\usepackage{hyperref}

\makeatletter
\newcommand\seteqn[1]{%
  \global\let\savetheEqn\theequation%
  \edef\@tempz{#1}%
  \def\@EqnNum{}%
  \edef\@currEqnCtr{\value{equation}}%
  \loop\ifnum\@tempz>0\relax%
    \xdef\@currEqnCtr{\number\numexpr\@currEqnCtr+1}%
    \xdef\@EqnNum{\ifx\@EqnNum\@empty\else\@EqnNum,\fi\@currEqnCtr}%
    \edef\@tempz{\number\numexpr\@tempz-1}%
  \repeat%
  \def\theequation{\@EqnNum}
}
\newcommand\reseteqn{\setcounter{equation}{\@currEqnCtr}%
  \global\let\theequation\savetheEqn}
\makeatother

\begin{document}

\begin{equation}\label{eqn1}
eqn:1
\end{equation}

\seteqn{2}
\begin{equation}\label{eqn2,3}
eqn:2,3
\end{equation}
\reseteqn

\begin{equation}\label{eqn4}
eqn:4
\end{equation}

\end{document}

enter image description here

1
  • Thanks :) it works but I'm just a new man in using LaTeX, maybe I should pay some time to learn the code you provided
    – Ice0cean
    Dec 19, 2015 at 10:59

You must log in to answer this question.

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