[Tex/LaTex] Placing the equation number in the left-hand margin

cross-referencingequationsformattingmarginsnumbering

I use

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

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

Equation number in margin

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:

Bad reference

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[left=5.6cm,right=2.2cm,top=5.5cm,bottom=3.55cm,headsep=1.9cm]{geometry}
\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}
\begin{equation}
a = b+c
\label{test}
\end{equation}

This is a reference (\ref{test})

\end{document}

Best Answer

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).

output_complete-code

Complete code

\documentclass[leqno,11pt,parskip,oneside]{scrartcl}
\usepackage{lipsum}
\usepackage[left=5.6cm,right=2.2cm,top=5.5cm,bottom=3.55cm,headsep=1.9cm]{geometry}
\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]    
\begin{equation}\label{test}
\dop^2_p = 2\cdot\dop^2_{\spot}\cdot\bigg(\frac{\Phi}{\Phi_{\low}}\bigg)
\end{equation}    
This is a reference \myeqref{test}. \lipsum[2]
\end{document}
Related Question