5

I changed the equation numbering format to avoid the 0 when I don't have subsubsection. Output ex. :

Equation (1.1.a)

instead of

Equation (1.1.0.a)

But now, when I use the \ref or the \eqref commands, they are extra spacing before the parenthesis. Output ex. :

( 1.1.a )

instead of

(1.1.a)

Do you have any solution?

Full Latex example :

\documentclass [11pt, twoside]{article}
\usepackage{amsmath}
\numberwithin{equation}{subsection}
\numberwithin{equation}{subsubsection}
\renewcommand{\theequation}{
  \ifnum\value{subsubsection}=0
  \thesubsection
  \else
  \thesubsubsection
  \fi
  .\alph{equation}
}

\begin{document}

\section{Section}

   \subsection{Subsection}
      \begin{equation}
       equation = 1
      \label{eq1}
      \end{equation}

      \subsubsection{Subsubsection}
         \begin{equation}
          equation = 2
         \label{eq2}
         \end{equation}

   \subsection{Ref.}
       Eqref for First equation \eqref{eq1}
       Ref for Second equation (\ref{eq2})

\end{document}

Output :

Output

Roxane
  • 53

2 Answers2

6

Unprotected end of lines! See

\renewcommand{\theequation}{% <--- HERE
  \ifnum\value{subsubsection}=0
  \thesubsection
  \else
  \thesubsubsection
  \fi
  .\alph{equation}% <--- HERE
}

enter image description here

egreg
  • 1,121,712
4

Please observe percent signs in lines marked here:

\documentclass [11pt, twoside]{article}
\usepackage{amsmath}
\numberwithin{equation}{subsection}
\numberwithin{equation}{subsubsection}
\renewcommand{\theequation}{% here
  \ifnum\value{subsubsection}=0
  \thesubsection
  \else
  \thesubsubsection
  \fi
  .\alph{equation}% here
}

\begin{document}

\section{Section}

   \subsection{Subsection}
      \begin{equation}
       equation = 1
      \label{eq1}
      \end{equation}

      \subsubsection{Subsubsection}
         \begin{equation}
          equation = 2
         \label{eq2}
         \end{equation}

   \subsection{Ref.}
       Eqref for First equation \eqref{eq1}
       Ref for Second equation (\ref{eq2})

\end{document}

enter image description here