1

I want to append the current section to equation tags, even if I use the \tag command to override it. I would guess this entails creating some custom command like \appendtag.

I know I can use \numberwithin{equation}{section} to add the section number to the tags. I actually use \renewcommand{\theequation}{\arabic{section}--\arabic{equation}}, because I prefer a dash over the dot. However, if I use the \tag command, I override the whole tag (as in equation (Ex) below). What I wish to do is just append some text, so that the equation tag reads (1-Ex).

\documentclass{article}
\usepackage{amsmath}
\renewcommand{\theequation}{\arabic{section}--\arabic{equation}}

\begin{document}

\section{First}

We have an untagged equation like
\begin{equation}
    y = X\beta + \varepsilon,
\end{equation}
with a second untagged equation like
\begin{equation}
    E(\varepsilon_i | X) = 0. \tag{Ex}
\end{equation}

\end{document}

enter image description here

1
  • In (1-Ex), the number would be the section number? And is it always the same text that would be appended?
    – Bernard
    Apr 15 '19 at 23:12
4

enter image description here

\documentclass{article}
\usepackage{amsmath}
\renewcommand{\theequation}{\arabic{equation}}
\makeatletter
\def\tagform@#1{\maketag@@@{(\arabic{section}--\ignorespaces#1\unskip\@@italiccorr)}}
\makeatother
\begin{document}

\section{First}

We have an untagged equation like
\begin{equation}
    y = X\beta + \varepsilon,
\end{equation}
with a second untagged equation like
\begin{equation}
    E(\varepsilon_i | X) = 0. \tag{Ex}
\end{equation}

\end{document}
1

You can use \tag to achieve any format, and \label and \ref will reproduce them. The only difference is that \tag turns off the automatic \stepcounter{equation}.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\section{First}

We have an untagged equation like
\begin{equation}\stepcounter{equation}
    y = X\beta + \varepsilon, \tag{\thesection-\theequation}
\end{equation}
with a second untagged equation like
\begin{equation}\stepcounter{equation}
    E(\varepsilon_i | X) = 0. \tag{\theequation-Ex}
\end{equation}

\end{document}

demo

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.