1

I want to add a line of dots between equation and equation numbers just like this: enter image description here And I got an answer from here

\begin{equation}
    \hskip \textwidth minus \textwidth
    \sin^2{\theta}+\cos^2{\theta}=1
    \leaders\hbox{$\cdot$ }\hskip \textwidth minus \textwidth
\end{equation}

However, it doesn't work in the eqnarray environment

\begin{eqnarray}
    {f_1(x)=12x^2+36x+\sin x}
    f_2(x)=\sqrt{3}{x^3+3x}
\end{eqnarray}

EDIT: Finally,my solution looks like this:

\newlength{\eqlength}
\newlength{\numlength}
\newlength{\dotlength}
\newlength{\frontlength}
\newcounter{eq}[chapter]
\stepcounter{eq}
\newcommand{\drawdots}[2][0pt]{
    #2
    \stepcounter{eq}
    \settowidth{\eqlength}{$#2$}
    \settowidth{\numlength}{(\thechapter.\theeq)}
    \setlength{\dotlength}{0.5\textwidth-0.5\eqlength-\numlength}
    \addtolength{\dotlength}{#1}
    \makebox[0em][l]{\leaders\hbox{ $\cdot$}\hskip \dotlength}
}

\let\normeq\equation
\let\endnormeq\endequation
\renewenvironment{equation}{
    \normeq
    \drawdots
}{
    \endnormeq
}
\begin{equation}
    {\sin^2{\theta}+\cos^2{\theta}=1}
    \label{eq:pingfanghe}
\end{equation}
\begin{align}
    &\drawdots{f_1(x)=12x^2+36x+\sin x}\\
    &\drawdots[4ex]{f_2(x)=\sqrt{3}{x^3+3x}}
    \label{eq:fx2}
\end{align}

enter image description here enter image description here

  • Welcome to Tex.SE! Did you check: https://tex.stackexchange.com/questions/45275/tikz-get-values-for-predefined-dash-patterns – tachyon Dec 09 '19 at 11:59
  • 2
    Please don't use eqnarray. Here's one explanation: http://www.tug.org/pracjourn/2006-4/madsen/ – Fintan Dec 09 '19 at 12:01

2 Answers2

2

Use \dotfill

\documentclass{article}
\usepackage{amsmath,amssymb}

\begin{document}

\begin{equation}
      \sin^2{\theta}+\cos^2{\theta}=1\makebox[20em]{\dotfill}
\end{equation}

\begin{equation}
\begin{cases}
    f_1(x) &=12x^2+36x+\sin x \\
    f_2(x)&=\sqrt{3}{x^3+3x}\makebox[20em]{\dotfill}
\end{cases}
\end{equation}

\end{document}

enter image description here

Cragfelt
  • 4,005
1

Can the following solution be applied?

\documentclass[12pt]{article} 
\usepackage{amsmath}

\begin{document}

\begin{equation}
    \hskip \textwidth minus \textwidth
    \sin^2{\theta}+\cos^2{\theta}=1
    \leaders\hbox{$\cdot$ }\hskip \textwidth minus \textwidth
\end{equation}
\begin{eqnarray}
\hskip 0.3\textwidth
 f_1(x)=12x^2+36x+\sin x
 \leaders\hbox{$\cdot$ }\hskip 0.3\textwidth  \\
 f_2(x)=\sqrt{3}x^3+3x
 \leaders\hbox{$\cdot$ }\hskip 0.3\textwidth 
\end{eqnarray}

\end{document}

enter image description here