[Tex/LaTex] How to automatically number an equation like this
equationsnumbering
Related Solutions
Here's one way (taken some code from Input manually a number into \eqref
):
\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/
\makeatletter
\newcommand{\eqnum}{\refstepcounter{equation}\textup{\tagform@{\theequation}}}
\makeatother
\begin{document}
\begin{equation}
f(x) = ax^2 + bx + c \label{myeqn1}
\end{equation}
See~\eqref{myeqn1}. Also
\begin{itemize}
\item $A$ is very~$b$, \eqnum\label{myeqn2}
\item $A$ is not~$c$. \eqnum\label{myeqn3}
\end{itemize}
There is also~\eqref{myeqn2} and~\eqref{myeqn3}.
\end{document}
The above MWE provides \eqnum
which inserts the equation number using the amsmath
\eqref
way. A subsequent \label
makes one able to reference it. Of course, the print-and\label
technique could be combined, if needed:
\makeatletter
\newcommand{\eqlab}[1]{\refstepcounter{equation}\label{#1}\textup{\tagform@{\theequation}}}
\makeatother
which allows one to use \eqlab{<label>}
.
For flushed-right equation numbering, use the following definition:
\newcommand{\eqnum}{\leavevmode\hfill\refstepcounter{equation}\textup{\tagform@{\theequation}}}
Assuming that these numbered quote environments are at the top level and not nested in other list environments, you can exploit the fact that, unless your equation numbers are too wide, they will fit in the available white space; in case they are wider for fitting, you should redefine quote
in the first place.
\documentclass{article}
\usepackage{blindtext}
\newsavebox\ideabox
\newenvironment{idea}
{\begin{equation}
\begin{lrbox}{\ideabox}
\begin{minipage}{\dimexpr\columnwidth-2\leftmargini}
\setlength{\leftmargini}{0pt}%
\begin{quote}}
{\end{quote}
\end{minipage}
\end{lrbox}\makebox[0pt]{\usebox{\ideabox}}
\end{equation}}
\begin{document}
\begin{quote}\blindtext\end{quote}\begin{equation}E=mc^2\end{equation}
\begin{idea}
\blindtext
\end{idea}
\end{document}
The “equationed” quote is typeset in a zero width box, so the equation number will not force a shift to the left.
Best Answer
Not fundamentally different from GuM's answer, but some improvements to ease typing partial derivatives with
esdiff
and cross-referencing withcleveref
(to be loaded afterhyperref
, if you use it):