# Placing the equation number in the left-hand margin

I use

\renewcommand{\theequation}{{\hspace*{-3.05cm}\thesection.\arabic{equation}}}


to move my equation numbers into the margins (corporate design), it looks like this:

The problem is that apparently this command is also used to make references in the text, so when doing (\ref{equation:label}) I get this:

As you can see, everything behind the ( gets pulled to the left by 3.05cm, as defined above. Is there any way to get the references and equation environment to use different commands for the equation numbers so I can define them the way I need them?

## Edit

Here is a MWE:

\documentclass[leqno,11pt,parskip,oneside]{scrartcl}
\usepackage{mathtools}
\usepackage[hyperref]{xcolor}
\usepackage{chngcntr}

\counterwithin*{equation}{section}

% remove brackets from equation numbers
\newtagform{brackets}{}{}
\usetagform{brackets}

% Equation numbers
\renewcommand{\theequation}{{\fontsize{8bp}{8bp}\selectfont\hspace*{-3.05cm}\thesection.\arabic{equation}}}

\begin{document}
\section{TestSection}
$$a = b+c \label{test}$$

This is a reference (\ref{test})

\end{document}


As you are using mathtools you alredy have all the tools(!) you need. You even invoked the right macro, \newtagform -- in which you can specify how your tags should be formatted:

\newtagform{brackets}{\hspace*{-3.05cm}\fontsize{8bp}{8bp}\selectfont}{}


Doing so, you need to take care \eqref (as it uses \tagform@ which like in the solution of @DavidCarlisle gets redefined; only with less effort ;)

You can use the patch of Davids solution to fix this or define a custom command:

\newcommand{\myeqref}[1]{\textup{(\ref{#1})}}


which omits \tagform@. Alternatively you could also \renewcommand\eqref itself to this form (shouldn't be harmfull, but I can't say this for sure now).

### Complete code

\documentclass[leqno,11pt,parskip,oneside]{scrartcl}
\usepackage{lipsum}
\usepackage{mathtools}
\newtagform{brackets}{\hspace*{-3.05cm}\fontsize{8bp}{8bp}\selectfont}{}
\usetagform{brackets}
\renewcommand{\theequation}{\thesection.\arabic{equation}}
\usepackage[hyperref]{xcolor}
\usepackage{chngcntr}
\counterwithin*{equation}{section}

\newcommand{\myeqref}[1]{\textup{(\ref{#1})}}% or
%\renewcommand{\eqref}[1]{\textup{(\ref{#1})}}

%for testing purposes
\DeclareMathOperator{\dop}{d}
\DeclareMathOperator{\spot}{spot}
\DeclareMathOperator{\low}{lower}

\setcounter{section}{6}

\begin{document}
\section{Test section}
\lipsum[1]
$$\label{test} \dop^2_p = 2\cdot\dop^2_{\spot}\cdot\bigg(\frac{\Phi}{\Phi_{\low}}\bigg)$$
This is a reference \myeqref{test}. \lipsum[2]
\end{document}

• Thanks, I was not aware that \newtagform could do this. Since I only use \ref, this is the most elegant solution for me. – user3696412 Aug 4 '15 at 10:29

Redefinining \theequation in that way is wrong. The LaTeX \thezzzz macros are supposed to be safe to expand in tables of contents and other expansion contexts to the formatting of just the number.

The code to position the number should be elsewhere. If you are using amsmath then the macro to redefine is \maketag@@@

which has default definition

\def\maketag@@@#1{\hbox{\m@th\normalfont#1}}


with the MWE now supplied:

\documentclass[leqno,11pt,parskip,oneside]{scrartcl}
\usepackage{mathtools}
\usepackage[hyperref]{xcolor}
\usepackage{chngcntr}

\counterwithin*{equation}{section}

% remove brackets from equation numbers
\newtagform{brackets}{}{}
\usetagform{brackets}

% Equation numbers
\renewcommand{\theequation}{\thesection.\arabic{equation}}

\makeatletter
\let\oldmaketag@@@\maketag@@@
\def\oldtagform@#1{\oldmaketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}
\renewcommand{\eqref}[1]{\textup{\oldtagform@{\ref{#1}}}}
\def\maketag@@@#1{\hbox{\hskip1sp\m@th\llap{%
\fontsize{8bp}{8bp}\normalfont\normalcolor
\normalfont#1\hspace{3.05cm}%
}}}
\makeatother

\begin{document}
\section{TestSection}
$$a = b+c \label{test}$$

This is a reference (\ref{test})

This is a reference \eqref{test}

\end{document}

• Could you provide an example of how to insert own adjustments into that command? I tired \def\maketag@@@#1{\hbox{\m@th\hspace*{-3.05cm}#1}} but nothing happens, the equation number is not moved in any way. – user3696412 Aug 4 '15 at 9:17
• @user3696412 see update, now you have supplied a MWE:-) – David Carlisle Aug 4 '15 at 9:40
• Interestingly, the position of the cross-reference is correct if it's generated via \ref, but it's not if generated via \eqref. – Mico Aug 4 '15 at 9:47
• Thanks a lot, works now like a charme. However, I will use Ruben solution since I already have that \newtagform call in there and only need to add in that line. – user3696412 Aug 4 '15 at 10:30