0

I want to manually numbering in non-numbered displayed equation environment and try the following steps

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\[
\bar{D}=\frac{1}{n} \sum_{j=1}^{n} D_{j}, \quad s_{d}^{2}=\frac{1}{n-1} \sum_{j=1}^{n}\left(D_{j}-\bar{D}\right)^{2}
\tag{6-1}
\]

\begin{equation*}
\bar{D}=\frac{1}{n} \sum_{j=1}^{n} D_{j}, \quad s_{d}^{2}=\frac{1}{n-1} \sum_{j=1}^{n}\left(D_{j}-\bar{D}\right)^{2}
\tag{6-1}
\end{equation*}

\end{document}

Which works successfully.

Since the R Markdown in Rstudio and the Markdown in Typora support the automatic-displaying of equations in double dollar signs ($$...$$), I sometimes need manually numbering with \tag in double dollar signs, even if I know people prefer to recommend using \[...\] and \begin{equation*}...\end{equation*} instead of using $$...$$.

I tried

$$
\bar{D}=\frac{1}{n} \sum_{j=1}^{n} D_{j}, \quad s_{d}^{2}=\frac{1}{n-1} \sum_{j=1}^{n}\left(D_{j}-\bar{D}\right)^{2}
\tag{6-1}
$$

and it showed normally and correctly in Rstudio (.Rmd) and Typora (.md), but showing errors in my Texstudio+Texlive2019, with

! Package amsmath Error: \tag not allowed here.

My question is if I insist using manually numbering with \tag in double dollar signs ($$...$$), what should I do?

4
  • I also came up with a way that might work in Rstudio (.Rmd), Typora (.md) and TeXstudio (.tex) at the same time, with a command added in the preamble as \renewenvironment{$$}{\[}{\]}. However, it showed a error ! LaTeX Error: Environment $$ undefined. – John Stone May 19 at 2:37
  • 1
    as wipet says, if you are using tex primitive syntax you can use \eqno but it must surely be possible to get R markdown to generate better latex than this. whether you use $$ or \[ there should never be a blank line before the display, as it generates a spurious one line paragraph with an empty line just containing an identation box. – David Carlisle May 19 at 6:56
  • @DavidCarlisle Thank you for your reply! I know \eqno or \feqno for $$...$$, but Rstudio (.Rmd) and Typora (.md) don't support the automatic-displaying (i.e., you don't need to compile it!) the manually numbering with \eqno or \feqno. Of course, with compilation, there are many better choices other than $$...$$. Why I insist using $$...$$ with \tag is to unify Rstudio (.Rmd), Typora (.md) and Texstudio (.tex) without any extra coding overhead. – John Stone May 21 at 14:54
  • 1
    but it doesn't have no coding overhead as you need to define it (to be \eqno )otherwise it won't work. – David Carlisle May 21 at 16:13
1

Use TeX primitive \eqno instead LaTeX macro \tag:

$$
\bar{D}=\frac{1}{n} \sum_{j=1}^{n} D_{j}, \quad s_{d}^{2}=\frac{1}{n-1} \sum_{j=1}^{n}\left(D_{j}-\bar{D}\right)^{2}
\eqno\hbox{(6-1)}
$$
1
  • Thank your for your answer! Please see my responses to David Carlisle. Tks again! – John Stone May 21 at 14:56

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.