[latex3-commits] [git/LaTeX3-latex3-latex2e] gh373: Add ltnews entry for \ShowCommand (b7b22fbc)

PhelypeOleinik tex.phelype at gmail.com
Thu Aug 20 23:07:01 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : gh373
Link       : https://github.com/latex3/latex2e/commit/b7b22fbcc817b6050045a300def2ef0c40c0c512

>---------------------------------------------------------------

commit b7b22fbcc817b6050045a300def2ef0c40c0c512
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Thu Aug 20 18:07:01 2020 -0300

    Add ltnews entry for \ShowCommand


>---------------------------------------------------------------

b7b22fbcc817b6050045a300def2ef0c40c0c512
 base/doc/ltnews32.tex | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/base/doc/ltnews32.tex b/base/doc/ltnews32.tex
index 71d89ecd..4483e2a5 100644
--- a/base/doc/ltnews32.tex
+++ b/base/doc/ltnews32.tex
@@ -521,7 +521,7 @@ are ignored as elsewhere.
 \githubissue{327}
 
 
-\subsection{Provide a way to copy commands}
+\subsection{Provide a way to copy robust commands\ldots}
 
 With the previous \LaTeXe{} release, several user-level commands were
 made robust, so the need for a way to create copies of these commands
@@ -532,8 +532,8 @@ command \verb=\foo= to be copied to \verb=\bar= with
 \verb=\LetLtxMacro\bar\foo=.
 
 From this release onwards, the \LaTeXe{} kernel provides
-\cs{NewCommandCopy} (and \verb=\Renew...=, \verb=\Declare...=, and
-\verb=\Provide...= variants) which functions almost like
+\cs{NewCommandCopy} (and \verb=\Renew...= and \verb=\Declare...=
+variants) which functions almost like
 \verb=\LetLtxMacro=.  To the end user, both should work the same way,
 and one shouldn't need to worry about the definition of the command:
 \cs{NewCommandCopy} should do the hard work.
@@ -543,9 +543,41 @@ the \LaTeXe{} kernel, and also from other packages, such as
 \pkg{xparse}'s command declarations like \cs{NewDocumentCommand}, and
 \pkg{etoolbox}'s \cs{newrobustcmd}, and it can be extended to cover
 further packages.
-
+%
 \githubissue{239}
 
+
+\subsection{\ldots\ and a way to \cs{show} them}
+
+It is sometimes necessary to look the definition of a command, and often
+one not only doesn't know where that command is defined, but doesn't
+know if it gets redefined by some package, so often enough looking at
+the source doesn't help.  The typical way around this problem is to use
+\TeX's \cs{show} primitive to look at the definition of a command, which
+works fine until the command being \cs{show}n is robust.  With
+\verb=\show\frac= one sees
+\begin{verbatim}
+> \frac=macro:
+->\protect \frac  .
+\end{verbatim}
+which is not too helpful.  To show the actual command the user needed to
+notice that the real definition of \cs{frac} is in the \verb*=frac = %*
+macro and do \verb=\expandafter\show\csname frac\space\endcsname=.
+
+But with the machinery for copying robust commands in place it is
+already possible to examine a command and detect (as far as a macro
+expansion language allows) how it was defined.  \cs{ShowCommand} knows
+that and with \verb=\ShowCommand\frac= the terminal will show
+\begin{verbatim}
+> \frac=robust macro:
+->\protect \frac  .
+
+> \frac =\long macro:
+#1#2->{\begingroup #1\endgroup \over #2}.
+\end{verbatim}
+%
+\githubissue{373}
+
 \subsection{Merge \pkg{l3docstrip} into \pkg{docstrip}}
 
 The file \pkg{l3docstrip.tex} offered a small extension over the





More information about the latex3-commits mailing list.