0

I would like to display longer labels given to sections, theorems, and equations in the margin with line breaks so they do not extend outside the margin. I tried the two answers to this question, but neither works with the informs3 document class.

---------- How existing methods fail - Feel free to skip ----------

For the first answer given there, each character in the label wil display in a separate line: Result from the first answer

For the second answer, the label will extend into the text body of the page: Result from the second answer

---------- End of how existing methods fail ----------

Ideally I want each label to be displayed so that it

  1. Takes up the entire horizontal space of the margin: from the edge of the paper to the edge of the text body;
  2. Replaces each blank space with an "open box" (␣) symbol; and
  3. Breaks the line at any character as needed (including halfway through a word, so that goal #1 is met).

Of course, the label display should not otherwise change the presentation of the document.

Here is a MWE:

    \documentclass{informs3}
    
    %Existing methods to display the label
    
    %Method 1 (does not work)
    %\usepackage{seqsplit}
    %\usepackage{showkeys}
    %\usepackage{xstring}
    %\renewcommand*\showkeyslabelformat[1]{%
    %   \noexpandarg%
    %   % instead of \textvisiblespace you can also put in ~
    %   % if you want to keep a plain space at space characters
    %   \StrSubstitute{\(\{\)#1\(\}\)}{ }{\textvisiblespace}[\TEMP]%
    %   \parbox[t]{\marginparwidth}%
    %   {\raggedright\normalfont\small\ttfamily\expandafter\seqsplit\expandafter{\TEMP}}}
    
    %Method 2 (does not work)
    %\usepackage{showkeys}
    %\renewcommand*\showkeyslabelformat[1]{%
    %   \fbox{\parbox[t]{\marginparwidth}{\raggedright\normalfont\small\ttfamily#1}}}
    
    \TheoremsNumberedThrough %to define theorem-type environments
    
    \begin{document}
        
    \section{The Main Section} \label{sec:a really looooooooooooooooong label for a section}
    
    \begin{equation}
        a=b \label{eqn:a long label for an equation}
    \end{equation}
    
    \begin{theorem} \label{thm:a long label for a theorem}
        Example of a theorem with a long label.
    \end{theorem}
    
    \end{document}
    

1 Answer 1

2

Well the class sets \marginparwidth to zero and then your code is trying hard to fit the labels into this space. You can try something like this. labels will still overlap, but as there is not more space, there is not much to do about it:

\documentclass{informs3}
\usepackage[T1]{fontenc}
\usepackage{showkeys}
\ExplSyntaxOn
\renewcommand*\showkeyslabelformat[1]{%
 \fbox{\parbox[t]{1.5cm}{\SingleSpacedXI\raggedright\normalfont\small\ttfamily\str_map_inline:nn{#1}{##1\hspace{0pt}}}}}
\ExplSyntaxOff      
%    
\TheoremsNumberedThrough %to define theorem-type environments
    \def\blub{123}
    \begin{document}
        
    \section{The Main Section} \label{sec:a really_looooooooooooooooong label for a section}
    
    \begin{equation}
        a=b \label{eqn:a long label for an equation}
    \end{equation}
    
    \begin{theorem} \label{thm:a long label for a theorem}
        Example of a theorem with a long label.
    \end{theorem}
    
    \end{document}

enter image description here

1
  • It worked! Thank you! Is there some way to also replace each blank space in a displayed label with an "open box" (␣) symbol (goal #1)? Is there a way to make the line spacing of the displayed label even tighter (to reduce the overlap between adjacent labels)?
    – tvk
    Commented Dec 7, 2022 at 18:43

You must log in to answer this question.

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