Open eg9 opened 5 months ago
we could pull \DOTSB out of the protection but I think it might be better to use \protected\def
and then make the lookahead cope with a \protected
meaning (similar to how we added support for \newcommand
aka \long\def
a while back)
\documentclass{article}
% Any preamble code goes here
\usepackage{amsmath}
\makeatletter
{\uccode`9=`\p %
\uppercase{\gdef\stripprotected@#1#2#3\relax{%
\ifx9#2 \@xp\@xp\@xp\zap@to@space\fi}}}
\def\mdots@@{\gdef\thedots@{\dotso@}%
\ifx\@let@token\boldsymbol
\gdef\thedots@\boldsymbol{\boldsymboldots@}%
\else
\ifx,\@let@token \gdef\thedots@{\dotsc}%
\else
\ifx\not\@let@token
\gdef\thedots@{\dotsb@}%
\else
\keybin@
\ifgtest@ % if \keybin@ test
\gdef\thedots@{\dotsb@}%
\else
\xdef\meaning@{\meaning\@let@token. .........}%
\xdef\meaning@@{\@xp\striplong@\meaning@\relax\meaning@}%
% NEW BIT
\xdef\meaning@@{\@xp\stripprotected@\meaning@@\relax\meaning@@}%
% END NEW BIT
\@xp\math@\meaning@\math@
\ifgtest@ % if \mathxxx test
\@xp\mathch@\meaning@\mathch@
\ifgtest@ % if \mathchar
\@xp\getmathch@\meaning@\getmathch@
\fi % end if \mathchar
\else % \not \mathxxx
\@xp\Umathch@\meaning@"0"\Umathch@
\ifgtest@ % if \Umathchar
\else % else not \Umathcar
\@xp\macro@\meaning@@\macro@
\ifgtest@ % if macro test
\@xp\not@\meaning@\not@
\ifgtest@ % if macro starts \not test
\gdef\thedots@{\dotsb@}%
\else% else not \not
\@xp\DOTS@\meaning@\DOTS@
\ifgtest@ % \if DOTS
\ifcase\number\DOTSCASE@ %ifcase dots
\gdef\thedots@{\dotsb@}%
\or\gdef\thedots@{\dotsi}\else
\fi % endifcase dots
\else % not macro starts \DOTS
\@xp\math@\meaning@\math@
\ifgtest@ % \if macro starts \mathxxxx
\@xp\mathbin@\meaning@\mathbin@
\ifgtest@ % if macro starts \mathbin
\gdef\thedots@{\dotsb@}%
\else % not macro starting \mathbin
\@xp\mathrel@\meaning@\mathrel@
\ifgtest@ % if macro starts \mathrel
\gdef\thedots@{\dotsb@}%
\fi % endif macro starts \mathrel (no else)
\fi % endif macro starts \mathbin
\fi % endif macro starts with \mathxxx (no else)
\fi % endif macro starts \DOTS else
\fi % end macro starting \not \ifgtest@ test (no else)
\else
\@xp\thecharacter@\meaning@\thecharacter@
\fi % end macro \ifgtest@ test (no else)
\fi % end if \Umathchar test
\fi % end \math@ \ifgtest@
\fi % end \keybin@ \ifgtest@ test (no else)
\fi % end if \not (no else)
\fi % end if comma (no else)
\fi % end if boldsymbol (no else)
\thedots@}
\protected
\def
\cong{\mathrel{\mathpalette\@vereq\sim}} % congruence sign
\makeatother
\begin{document}
% Demonstration of issue here
$\equiv\dots\equiv$
$\cong\dots\cong$
\end{document}
we could pull \DOTSB out of the protection but I think it might be better to use
\protected\def
and then make the lookahead cope with a\protected
meaning (similar to how we added support for\newcommand
aka\long\def
a while back)
agreed, but then we should alter this for all symbols that use \DOTSB etc, shouldn't we?
By the way where is \DOTSB in your code sample?
agreed, but then we should alter this for all symbols that use \DOTSB etc, shouldn't we?
probably or at least such a change gives a way forward for that to work.
By the way where is \DOTSB in your code sample?
it is not needed as once the lookahead can get past the \protected
(or we could make it work with the existing \DeclareRobstCommand
\protect
version) then it sees the \mathrel
so defaults to centred dots just a it does with \equiv
in the example (which also has no \DOTS...
prefix).
wouldn't it be better to also handle robust macros of the form \protect\foo<space>
by dropping the \protect and expanding the second macro? There are quite a number of symbols defined with \DeclareRobustCommand
.
E.g., something like
+
+\def\stripprotect@#1#2\stripprotect@#3{\ifx#1\protect
+ \meaning#2\else
+ \meaning#3\fi. }
+
\def\mdots@@{\gdef\thedots@{\dotso@}%
\ifx\@let@token\boldsymbol
\gdef\thedots@\boldsymbol{\boldsymboldots@}%
\else
\ifx,\@let@token \gdef\thedots@{\dotsc}%
\else
\ifx\not\@let@token
\gdef\thedots@{\dotsb@}%
\else
\keybin@
\ifgtest@ % if \keybin@ test
\gdef\thedots@{\dotsb@}%
\else
% \end{macrocode}
% \changes{v2.15d}{2016/06/28}{Add space token to prevent runaway argument error}
% \begin{macrocode}
- \xdef\meaning@{\meaning\@let@token. .........}%
+ \begingroup
+ \def\protect{\protect}% % make it a quark
+ \xdef\meaning@{\@xp\stripprotect@\@let@token. .........\stripprotect@\@let@token}%
+ \endgroup
% \end{macrocode}
% In previous versions \verb|\long| macros were not seen by the lokkahead.
% That was bad as this file uses \verb|\(re)newcommand| for \verb|\implies| etc.
% \begin{macrocode}
\xdef\meaning@@{\@xp\striplong@\meaning@\relax\meaning@}%
@FrankMittelbach yes we should make \protect
and \protected
robust macros work
@davidcarlisle does my code look reasonable (not sure I fully got the issues with "space" and all the dots (the latter presumably to have something for up to 9 arguments)) or do you see a better way to do this?
@FrankMittelbach I'll look later: not at home today
@FrankMittelbach looks good, I just wonder if having got that far we should go further and f-expand the token so that DOTSB hidden by macro exapnsion not just by macro expansion with \protect
would work (you'd have to use a \noexpandrather than a quak version of
\protect` probably.
specifically should the last, case e
give centred dots here or is the system not seeing DOTSB in that case a feature
\documentclass{article}
\usepackage{amsmath}
\def\wibble#1#2#3{}
\def\aaa{\DOTSB ,\wibble xyz}
\protected\def\aab{\DOTSB ,\wibble xyz}
\def\aac{\protect\aaa}
\long\def\aad{\DOTSB ,\wibble xyz}
\def\aae{\aaa}
\begin{document}
$,\dots \aaa$ a\par
$,\dots \aab$ b\par
$,\dots \aac$ c\par
$,\dots \aad$ d\par
$,\dots \aae$ e\par
\end{document}
almost all the tokens we test for are unexpandable primitives so mostly f-expanding the token and testing just the first non expandable token wouldn't require much change
Brief outline of the bug
While
\dots
does magic when used between symbols, it doesn't when the following symbol is\cong
Minimal example showing the bug
Log file (required) and possibly PDF file
Possible solution:
Take the standard definition of
\cong
, that's not changed byamsmath
and perform the standard works byamsmath
Adding
\DOTSB
to the original code for\cong
doesn't work because of\DeclareRobustCommand
. However, using\protected\def
wouldn't do anyway.The workaround code would result in
\DOTSB \cong@
written in the aux file, but that's normal and also\sum
would lead to\DOTSB\sum@
, for instance.