0

I am writing an equation using the following

\begin{eqnarray}
\max\{|P_4|\} = \frac{m+2}{2}
\end{eqnarray}

which gives me output in the following way:

enter image description here

Can I insert the equation with equation number just after text? Is it possible to do so? It is taking too much space on a page and I have to write at least six such equations. Kindly help.

  • 1
    (1) never use eqnarray, see tex.stackexchange.com/a/197/3929, (2) it will probably be very bad for the reader if the (1) is hidden as a part of the text, they will see it as a reference to an equation number they cannot find. – daleif May 2 '18 at 13:39
2

I am not sure whether this is what you had in mind, I can delete this post otherwise.

\documentclass[]{article}

\usepackage{hyperref}

% https://tex.stackexchange.com/questions/78579/labelled-in-line-equation
\makeatletter
\newcommand*{\inlineequation}[2][]{%
  \begingroup
    % Put \refstepcounter at the beginning, because
    % package `hyperref' sets the anchor here.
    \refstepcounter{equation}%
    \ifx\\#1\\%
    \else
      \label{#1}%
    \fi
    % prevent line breaks inside equation
    \relpenalty=10000 %
    \binoppenalty=10000 %
    \ensuremath{%
      % \displaystyle % larger fractions, ...
      #2%
    }%
    ~\@eqnnum
  \endgroup
}
\makeatother


\begin{document}

A shortest $u_0-u_i$ path is $P_1:u_0,v_0,v_3,v_6,\cdots,v_i,u_i$ containing $i/3$ 
edges from $C_1$ and two edges from $M$. Length of $P_1$ is $(i+6)/2$ and maximum
of $P_1$ is for $i=3m/2$, i.e., \inlineequation[eq:inline]{\max\{|P_4|\} = (m+2)/2}\\

Now a reference to Eq.~(\ref{eq:inline}), which states that 
\end{document}

enter image description here

  • Up to some extent this solved my problem. Thanks a lot. Really helpful – monalisa May 2 '18 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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