I'm trying to reference equation by \eqref
when I use different tags form throughout document, but the output can't display the tag form that I want. As mentioned in mathtools
package usage, "be careful" in this situation.
The display equation I want is "c+d=e [1-3]" but it only work in equation
environment. The reference I want is "There is a test in (1-2), [1-3], [1-4] and [1-5]." So
1. How can I get the result I say above ?
2. If I don't change those code in math mode, how can I custom the command or use which package to display correct tag form and reference ?
3. Why does the equation
environtment display different from other math environment?
I'm using XeLaTeX under texlive2015.
Here is my code:
\documentclass{article}
\usepackage[pdfborder=0 0 0]{hyperref} % must needed
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
\newtagform{real}{[}{]}
\renewcommand{\theequation}{\arabic{subsection}--\arabic{equation}}
\newcommand{\zzreal}{\usetagform{real}\stepcounter{equation}\tag{\theequation}} %
\section{Sample}
\subsection{subsample}
\begin{align}
a+b &=c\\
b+c &=d \label{eq:2}\\
c+d &=e \zzreal \label{eq:3}
\end{align}
\begin{gather}
c+d =g \zzreal\label{eq:4}
\end{gather}
\begin{equation}
d+e =f \zzreal\label{eq:5}
\end{equation}
There is a test in \eqref{eq:2}, \eqref{eq:3} , \eqref{eq:4} and \eqref{eq:5} .
\end{document}
In addition, I have another code to satisfy the 1st question but not the requirement of 2nd question i.e I insert a command after each equation no matter whether I refer them or not. However, it seems inconvenient when writing the equation. Any workaround to optimize this code ?
Desired Result code:
\documentclass{article}
\usepackage[pdfborder=0 0 0]{hyperref} % must needed
\usepackage{amsmath}
\usepackage{mathtools}
\renewcommand{\theequation}{\arabic{subsection}--\arabic{equation}}
\new} command{\zzreal}{\refstepcounter{equation}\tag*{[\theequation]}}%
\newcommand{\zzsim}{\stepcounter{equation}\tag*{(\theequation)}}
\begin{document}
\section{Sample}
\subsection{subsample}
\begin{align}
a+b &=c \zzsim \\
b+c &=d & \zzsim \label{eq:2} \\
c+d &=e &\zzreal \label{eq:3}
\end{align}
\begin{gather}
c+d =g \zzreal\label{eq:4}
\end{gather}
\begin{equation}
d+e =f \zzreal\label{eq:5}
\end{equation}
There is a test in \ref{eq:2}, \ref{eq:3}, \ref{eq:4} and \ref{eq:5} .
\end{document}
gather
andalign
process each cell and line in a group, so when the tag is typeset, the setting of the tag form has been forgotten.