Equation and aligning

I need help. I need to write these equations in LaTeX, I wrote it like this:

\newcounter{defcounter}
\setcounter{defcounter}{23}
\newenvironment{myequation}%
\refstepcounter{defcounter}%
\renewcommand\theequation{D.\thedefcounter}%
$$}% {$$%
}

\begin{myequation}
(x^{\alpha})' \ = \ \alpha x^{\alpha -1}, \ \alpha \in \mathbb{R}, \ x \in
\mathbb{R}
\end{myequation}

\begin{myequation}
(\log_a{x})' \ = \ \frac{1}{x}\log_a{e}, \ x>0 \\
\end{myequation}


to get the numbers on the right side. I also have a Section so if I use align he automatically put number 2.3 which I don't need

• I think you should rather use \begin{align} ...\end{align} instead of such $$...$$ wrapper. equation itself is numbered already, so there is no need to number it again with a different counter, in my point of view. – user31729 Apr 5 '17 at 14:14
• it is myequation because i need to have D.24 if i put only equation it will be numbered as 1 – Ana Leko Apr 5 '17 at 14:20
• You could as well set equation to 23 – user31729 Apr 5 '17 at 14:24

In most cases such wrapper environments are not really well-designed and the alignment can be done with align as well.

\documentclass{article}

\usepackage{mathtools}
\usepackage{amsfonts}

\renewcommand\theequation{D.\arabic{equation}}
\begin{document}

\setcounter{equation}{23}
\begin{align}
(x^{\alpha})'  &=  \alpha x^{\alpha -1}, \,\alpha \in \mathbb{R}, \, x \in
\mathbb{R} \\
(\log_a{x})'  &=  \frac{1}{x}\log_a{e}, \,x>0
\end{align}

\end{document}


• So here is another problem – Ana Leko Apr 5 '17 at 14:32