1

I wish to make some editor tools: when I am working only the draft of my document I want to display the 'name' of the equation (set by \label) after each equation. For example in case of

\begin{equation}
\label{eq::einstein}
E=mc^2
\end{equation}

I want to see something like

E=mc^2 (1)

(eq::einstein)

I have to tried to redefine \label to store the parameter in \@currentlabelname then redefine environment equation to print \@currentlabelname after the equation (into a margin note box).

My MnWE:

\documentclass[a4paper]{article}

\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{amsmath}

\usepackage{marginnote}
\usepackage{tikz}
\setlength{\marginparwidth}{1.5cm}
\usepackage{todonotes}

\usepackage{regexpatch}
\makeatletter
\xpatchcmd{\@todo}{\setkeys{todonotes}{#1}}{\setkeys{todonotes}{size=\tiny,#1}}{}{}
\makeatother

\newcommand{\note}[2][yellow]{\todo[color=#1]{\tiny #2}}

\makeatletter
\let\oldlabel\label
%%
%% Problem occurs here
%%
\def\label#1{\oldlabel \gdef\@currentlabelname{#1}}

\let\Oldequation\equation
\let\Oldendequation\endequation
\renewenvironment{equation}{\Oldequation}{\Oldendequation \note[blue!90!black]{\textcolor{white}{\@currentlabelname}}}
\makeatother

\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{equation}
\label{equ::lenvente}
d_{twin}=\frac{1}{\beta}
\end{equation}

\lipsum[1]

\end{document}

Thank you for your time!

1

1 Answer 1

1

One obvious mistake in your example is

\def\label#1{\oldlabel \gdef\@currentlabelname{#1}}

as \oldlabel expects an argument (\let\oldlabel\label!) and is gobbling up \gdef. You could try to

\def\label#1{\oldlabel{#1} \gdef\@currentlabelname{#1}}

but anyways, what you want is easily achieved by

\documentclass{article}
\usepackage{xcolor}
\usepackage{showkeys}

\makeatletter
\renewcommand*\showkeyslabelformat[1]{\colorbox{blue!90!black}{\textcolor{white}{#1}}}

\makeatother

\begin{document}
\begin{equation}
  \label{equ::lenvente}
  d_{\mathrm{twin}}=\frac{1}{\beta}
\end{equation}
\end{document}

output

Not the answer you're looking for? Browse other questions tagged .