# HG changeset patch # User Norman Gray # Date 1614517200 0 # Sun Feb 28 13:00:00 2021 +0000 # Node ID 01a147ac38c34afd4f76b0bc2768fba9c3a08d7a # Parent 3e1ff9ef10de234c795bbeee7e249d519d775de4 Amend \showlabels optional argument to support one-arg macro. Also add `\showlabeltype` macro. This should end up as version 1.9, with a version bump to acknowledge that this is a non-trivial change in functionality. diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -6,13 +6,13 @@ # and check that the bundle does match the suggestions at # . -VERSION=1.8.1-SNAPSHOT +VERSION=1.9-SNAPSHOT RELEASEDATE=2016 June 9 # following must be yyyy/mm/dd RELEASEDATEN=2016/06/09 DIST=showlabels-$(VERSION) -COPYRIGHTYEARS=1999, 2001-09, 2013-16 +COPYRIGHTYEARS=1999, 2001-09, 2013-21 DISTFILES=showlabels.ins showlabels.dtx showlabels.html showlabels.pdf \ lppl.txt style.css diff --git a/showlabels.dtx.in b/showlabels.dtx.in --- a/showlabels.dtx.in +++ b/showlabels.dtx.in @@ -154,8 +154,8 @@ % \begin{quote} % |\renewcommand{\showlabelfont}{\small\slshape\color{green}}| % \end{quote} -% in the preamble of your document, as long as you have loaded the -% \Lpackage{color} package. +% in the preamble of your document (as long as you have loaded the +% \Lpackage{color} package, of course). % % Alternatively, the |\showlabels| command has an optional argument containing % formatting commands, which allows you to format |\cite| labels, for @@ -163,6 +163,12 @@ % \begin{quote} % |\showlabels[\color{green}]{cite}| % \end{quote} +% The optional formatting command can be either a font-changing +% command, as illustrated here, \emph{or} a command which takes a +% single argument, such as +% \begin{quote} +% |\showlabels[\fbox]{cite}| +% \end{quote} % % If, finally, you want complete control over the labels, you can % instead override |\showlabelsetlabel|, which initially expands to @@ -174,13 +180,25 @@ % \null\qquad |{\begin{turn}{60}\showlabelfont #1\end{turn}}|\\ % \end{quote} % then you end up with your labels at a jaunty angle in the margin. -% Finally, you can change the definition of the -% |\showlabelrefline| rule from its default, -% in order to change how the inline rule (see below) is displayed. +% +% The command |\showlabeltype| will expand to the current label type +% (ie, `label' or `cite', etc), so it would be possible for +% |\showlabelsetlabel| to conditionalise on that, if you felt that +% were necessary.\footnote{The support for an one-argument command in +% $\backslash$\texttt{showlabels}, and the presence of the +% $\backslash$\texttt{showlabeltype} macro, were added in version 1.9.} +% +% If instead you want to adjust how inline markings are displayed, you +% can change the definition of the +% |\showlabelrefline| rule from its default. % For example, defining this to be +% \begin{quote} % |\color{red}\hrule width 0.1em height 1.5ex depth 0pt | +% \end{quote} % produces a fattish red line, and defining it to be +% \begin{quote} % |\hrule width 0pt height 1.5ex depth 0pt| +% \end{quote} % suppresses the line but still positions the text between the lines. % % \subsection*{Compatibility with other packages, and other problems} @@ -468,7 +486,7 @@ % If you want slightly more general control over the labels, you can % instead override |\showlabelsetlabel|. % \begin{macrocode} -\providecommand{\showlabelsetlabel}[1]{{\normalfont\showlabelfont\SL@fmt@ #1}} +\providecommand{\showlabelsetlabel}[1]{{\normalfont\showlabelfont\SL@fmt@{#1}}} % \end{macrocode} % % For the benefit of |\SL@prlabelname|, define |\SL@gobblethree| to do nothing @@ -596,10 +614,22 @@ % it immediately, within the called macros. We call |\@sanitize| in % order to cope with eg |\index{Poincar\'e}| (see discussion of % |\SL@prlabelname| above). +% +% We declare |\showlabeltype| to be the `current' label type. It +% would be good to put this inside a group, so that it's only visible +% locally, but we would then have to be careful exactly when we closed +% the group: if we put it inside the group that's opened for +% |\@sanitize|, it would be closed too early to have an effect; if we +% open another group for |\showlabeltype|, then we'd have to close it +% \emph{after} |\SL@orig@@next|, where we risk colliding with whatever +% comes after it (and see above). It might be possible to be cleverer +% about this, but it's at least harmeless to have the command defined +% globally. % \begin{macrocode} \DeclareRobustCommand\SL@showlabels[1]{% \@bsphack \expandafter\let\expandafter\SL@orig@@next\csname SL@orig#1\endcsname + \def\showlabeltype{#1}% \begingroup\@sanitize \@ifstar {\SL@showlabelsplainstar} diff --git a/showlabels.html b/showlabels.html --- a/showlabels.html +++ b/showlabels.html @@ -105,9 +105,16 @@

History

-
1.8.X, YYYY MMM DD
-
Robustness fix: macros in arguments are now handled, so that -\index{Poincar\'e} doesn't cause an error.
+
1.9, YYYY MMM DD
+
    +
  • Robustness fix: macros in arguments are now handled, so that + (after \showlabel{index}), + \index{Poincar\'e} doesn't cause an error.
  • +
  • The \showlabel[optarg]{command} optional argument + can now take a one-argument command.
  • +
  • The macro \showlabeltype expands to the current + label type, for possible use in \showlabelsetlabel.
  • +
1.8, 2016 June 9
The ntheorem package exposed an apparently diff --git a/t/t19.tex b/t/t19.tex --- a/t/t19.tex +++ b/t/t19.tex @@ -1,6 +1,7 @@ %%% Testing: \index with macros; like t4, but not inline % Compare t4 \documentclass{article} +\usepackage{color} \parindent0pt \parskip\bigskipamount @@ -15,8 +16,9 @@ \usepackage{showlabels} \showlabels{cite} -\showlabels{begin} -\showlabels{ref} +\showlabels[\color{green}]{begin} +\def\reflabel#1{\fbox{#1} (\showlabeltype)} +\showlabels[\reflabel]{ref} \showlabels{index} \makeindex @@ -30,14 +32,15 @@ This is \label{s:s1_b text} some text. -And an equation: +And an equation (environments labelled in green): \begin{equation} \label{e:e a_1} % label with space and underscore E=mc^2, \end{equation} which we can refer to as \begin{itemize} -\item Eq.\ref{e:e a_1}, and -\item \cite{nobody_bar\'e}. +\item Eq.\ref{e:e a_1} (which should be labelled in a \texttt{fbox} + plus type), and +\item Citation \cite{nobody_bar\'e}. \end{itemize} \end{document}