Showkeys: Labels Out of Margin

1,120

this perhaps

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage[notref]{showkeys}
\renewcommand*\showkeyslabelformat[1]{%
  \fbox{\parbox[t]{\marginparwidth}{\raggedright\path{#1}}}}

\begin{document}

These are the constraint equations
\begin{align*}
\dot{x}  &=  \frac{R}{2}(\dot{\varphi_1}+\dot{\varphi_2})\sin\theta  \\
\dot{y}  &=  -\frac{R}{2}(\dot{\varphi_1}+\dot{\varphi_2})\cos\theta  \\
\theta-\theta_0   &=  \frac{R}{2L}(\varphi_1-\varphi_2)
\tag{1} 
\label{eq:constraint:final:integrated}
\end{align*}
\ref{eq:constraint:final:integrated} but the label seems to be out the paper!

\end{document}
Share:
1,120

Related videos on Youtube

Hosein Rahnama
Author by

Hosein Rahnama

Updated on August 01, 2022

Comments

  • Hosein Rahnama
    Hosein Rahnama over 1 year

    I use showkeys to manage my lablels. However, sometimes I would like to use long label names but it seems that showkeys does not like them! :)
    The problem is that the labels get out of the margin. I am aware of the two other similar questions

    but their solution does not seem to work in my case. Here is a MWE where the solution of David Carlisle suggested in the first question is implemented in it but the result is not satisfactory.

    \documentclass{article}
    \usepackage{amsmath}
    \usepackage{hyperref}
    \usepackage[notref]{showkeys}
    \renewcommand*\showkeyslabelformat[1]{%
      \fbox{\parbox[t]{\marginparwidth}{\raggedright\normalfont\small\ttfamily#1}}}
    
    \begin{document}
    
    These are the constraint equations
    \begin{align*}
    \dot{x}  &=  \frac{R}{2}(\dot{\varphi_1}+\dot{\varphi_2})\sin\theta  \\
    \dot{y}  &=  -\frac{R}{2}(\dot{\varphi_1}+\dot{\varphi_2})\cos\theta  \\
    \theta-\theta_0   &=  \frac{R}{2L}(\varphi_1-\varphi_2)
    \tag{1} 
    \label{eq:constraint:final:integrated}
    \end{align*}
    \ref{eq:constraint:final:integrated} but the label seems to be out the paper!
    
    \end{document}
    

    enter image description here

    • David Carlisle
      David Carlisle almost 7 years
      the major design requirement for showkeys was (as far as possible) not to affect the layout of the document, while giving a rough hint at the label usage. Not going out of the margin wasn't part of the design. You don't say what you want the package to do? (also why you want labels so long, rather than abc which is what I'd use!
    • Hosein Rahnama
      Hosein Rahnama almost 7 years
      @DavidCarlisle: I knew that you would say this! :) But I like to sometimes use long labels. I think this a matter of taste. :) However, that would be so nice, if this really good package could get this little issue done. :)
  • Hosein Rahnama
    Hosein Rahnama almost 7 years
    Thanks David. :) We all will be so thankful if you implement this in the package (to handle all the cases) in future versions so that this issue is solved once and for all. :)
  • David Carlisle
    David Carlisle almost 7 years
    @H.R. if you have lots of labels eg an align with a \label on every row, mult-line display of the labels really isn't going to work so I'm not sure what a general solution would be. i could add this as an example of the use of the labelformat customisation though if I ever update the package doc
  • Hosein Rahnama
    Hosein Rahnama almost 7 years
    Maybe you are right! :) There is no general solution! :) It is case dependent! And I just use one label for each align environment. :) So including different examples in the package documentation would be useful.