As per Xparse's new e-type argument (replacement for k-type argument), support for xparse
's k_
argument type is no longer available as of TeXLive 2016 and thus have stuck to TeXLive 2015 so far. I have numerous macros that are defined using the older k_
arguments, so wondering if there is an easy patch that I can apply so that I can use the new version of xparse
and still have the k_
macros work.
I am willing to discard the k_
and use the new e_
but don't like the idea of changing all the macros at once and then having to debug where things went wrong. If I have a single (patched) version of xparse
that supports both argument types, the transition will be a lot easier. Also, in case I run into some issue with TeXLive versions newer than 2015, I need to be able to revert back to TeXLive 2015 until I resolve any issues.
The solution I have below is too cumbersome due to the number of macros involved. Having a patch would allow me to use both as I transition to using the e_
argument types, and only revert to the solution below should I run into issues with newer versions.
References:
- Xparse's new e-type argument (replacement for k-type argument)
- Automatically Determine which TeXLive Version is being used
MWE
\documentclass{article}
\usepackage{xparse}
\usepackage{xcolor}
\makeatletter
%% https://tex.stackexchange.com/questions/96570/automatically-determine-which-texlive-version-is-being-used
\def\getversion{\expandafter\get@version\pdftexbanner\@nil}
\def\get@version#1201#2)#3\@nil{\def\TeXLiveVersion{201#2}}
\makeatother
\getversion
\ifnum\TeXLiveVersion<2016
\NewDocumentCommand\MyMacro{k_}{%
\IfNoValueTF{#1}{%
\mathbf{A}
}{%
A_{\textcolor{red}{#1}}
}%
}
\else
\NewDocumentCommand\MyMacro{e_}{%
\MyMacroProcess#1%
}
\NewDocumentCommand\MyMacroProcess{m}{%
\IfNoValueTF{#1}{%
\mathbf{A}
}{%
A_{\textcolor{red}{#1}}
}%
}
\fi
\begin{document}
With a subscript: $\MyMacro_{\pi}$
Without any subscript: $\MyMacro$
\end{document}
\@ifpackagelater{xparse}{2017/02/10}{this}{that}
– David Carlisle Mar 6 '17 at 22:02k_
option type was dropped before 2017-02-10. – Peter Grill Mar 6 '17 at 22:06#
in optional args, for example): see my answer here! – Joseph Wright♦ Mar 7 '17 at 9:26