6

maybe I am already looking at it, but I can't see it, so I would be glad if someone can give me a short hint.

\documentclass[12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\renewcommand{\theequation}{\textit{Eq. \thesection.\arabic{equation}}} 

\begin{document}

\section{Vogelpohlsche Volumenformel}
\begin{equation}
n = \frac{10^{-8} F}{6 C \cdot \eta \cdot V}
\label{eq:Example}
\end{equation}

A reference to the equation \ref{eq:Example} is helpful.

\end{document}

As with this MWE, I redefined the numeration of the equation that it appears on the right as "Eq. 1.1", which works fine. But when I am referencing the equation inside text, I normally write the whole word "equation" and add the reference. Here it gives me also the abbrevation for the reference ("A reference to the equation Eq. 1.1 is helpful."). What is the way to have the "Eq." in the numeration but not in the reference?

I want to avoid additional packages or so and I also looked up former questions like this one without seeing the solution

How to style equation label and reference differently?

Thanks for your input and have a nive day to you all!

Jäger
  • 327

3 Answers3

8

What you have done so far is to change the definition of \theequation so that it contains Eq.. This means that any reference created using \label and \ref will also contain Eq., which you don't want. As described in Changing the appearance of equation numbers with amsmath, you need to modify the \tagform@ macro. Since this command contains an at character @, which is a special character for (La)TeX so you need to do this inside \makeatletter....\makeatother. The following redefinition of \tagform@ does what you want:

\makeatletter
\def\tagform@#1{\maketag@@@{(\ignorespaces\textit{Eq.~#1}\unskip\@@italiccorr)}}
\makeatother

Notice that I have used Eq.~#1 rather than Eq. #1. This just adds Eq. to the original definition of \tagform@ from amsmath.sty, which is

\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}

As the Eq. is now added by \tagform@ your redefinition of \theequation is no longer needed. You still want the equations numbered inside sections, however, so this has to be taken care of. Rather than redefining \theequation it is better to use \numberwithin{equation}{section} because this will cause the equation counter to be reset whenever the section counter is incremented.

With these changes your MWE becomes:

\documentclass[12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\numberwithin{equation}{section}

\makeatletter
\def\tagform@#1{\maketag@@@{(\ignorespaces\textit{Eq.~#1}\unskip\@@italiccorr)}}
\makeatother

\begin{document}

\section{Vogelpohlsche Volumenformel}
\begin{equation}
n = \frac{10^{-8} F}{6 C \cdot \eta \cdot V}
\label{eq:Example}
\end{equation}

A reference to the equation \ref{eq:Example} is helpful.

\end{document}

and the output is:

enter image description here

  • 1
    irrelevant to intent of answer, but the name \tagform@ contains an at-sign, not an ampersand (&). also, wondering why the equation number is given in italic; upright is more traditional in publications i'm used to. – barbara beeton Dec 14 '16 at 14:33
  • @barbarabeeton Thanks. Will fix the ampersand...The equation numbers are in italics because this is what the OP used in their post and seems to want. –  Dec 14 '16 at 21:58
4

Is this what you need?

\documentclass[12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\renewcommand{\theequation}{\thesection.\arabic{equation}}

\makeatletter
\def\tagform@#1{\maketag@@@{(\ignorespaces\textit{Eq.\ #1}\unskip\@@italiccorr)}}
\renewcommand{\eqref}[1]{\textup{{\normalfont(\ref{#1}}\normalfont)}}
\makeatother

\begin{document}

\section{Vogelpohlsche Volumenformel}
\begin{equation}
n = \frac{10^{-8} F}{6 C \cdot \eta \cdot V}
\label{eq:Example}
\end{equation}

A reference to the equation \eqref{eq:Example} is helpful.

\end{document}

enter image description here

2

You can do it in a fairly general way:

\documentclass{article}
\usepackage{amsmath}
\numberwithin{equation}{section}

\makeatletter
% detach tags and references
\renewcommand{\eqref}[1]{\textup{\eqrefform@{\ref{#1}}}}
\let\eqrefform@\tagform@

\newcommand{\changetag}[1]{%
  \renewcommand\tagform@[1]{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}%
}
\makeatother

\begin{document}

\section{Normal}
Here is an equation
\begin{equation}
a=b\label{normal}
\end{equation}
In \eqref{normal} we see something.

\changetag{\textit{Eq.\ #1}}

\section{Changed}
Here is an equation
\begin{equation}
x=y\label{changed}
\end{equation}
In \eqref{changed} we see something.

\end{document}

enter image description here

Of course in a normal document you'd choose a single format for the tags.

The argument to \changetag is the formatting you want, where #1 stands for the equation number.

\documentclass{article}
\usepackage{amsmath}
\numberwithin{equation}{section}

\makeatletter
% detach tags and references
\renewcommand{\eqref}[1]{\textup{\eqrefform@{\ref{#1}}}}
\let\eqrefform@\tagform@

\newcommand{\changetag}[1]{%
  \renewcommand\tagform@[1]{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}%
}
\makeatother

\changetag{\textit{Eq.\ #1}}

\begin{document}

\section{First}
Here is an equation
\begin{equation}
a=b\label{a}
\end{equation}
In \eqref{a} we see something.

\section{Second}
Here is an equation
\begin{equation}
x=y\label{b}
\end{equation}
In \eqref{b} we see something.

\end{document}

enter image description here

egreg
  • 1,121,712