Tag Info

Hot answers tagged

9

You can redefine \polynomial to expand its argument: \documentclass{article} \usepackage{polynomial,xparse} \ExplSyntaxOn \cs_set_eq:NN \gonzalo_poly:n \polynomial \cs_generate_variant:Nn \gonzalo_poly:n { x } \RenewDocumentCommand{\polynomial}{m} { \gonzalo_poly:x { #1 } } \ExplSyntaxOff \begin{document} \begin{figure} \def\a{-3} \def\b{-2} ...


7

You need to force expansion of the arguments before \polynomial. A typical approach would be \documentclass{article} \usepackage{polynomial} \begin{document} \def\a{-3} \def\b{-2} \def\c{-4} \[ \begingroup\edef\x{\endgroup\noexpand\polynomial{\a,\b,\c}}\x \quad\polynomial{-3,-2,-4} \] \end{document} assuming that \a, \b and \c can be taken to be fully ...


6

You can declare a robust command so it is safe in a caption: \documentclass{article} \usepackage{polynomial} \DeclareRobustCommand\xpolynomial[1]{% \edef\next{\noexpand\protect\noexpand\polynomial{#1}}\next} \begin{document} \listoftables \begin{table} \def \a{-3} \def\b{-2} \def \c{-4} \caption{$\xpolynomial{\a,\b,\c}$} \end{table} zzzz ...


6

Luckily I discovered that the two problems mentioned in the OP are really the only ones and that they are solvable straight forward, after(!) trying out lots of other things :) The expansion problem is solved by a simple \expandafter "before" detokenizing the result (i.e. \detokenize\expandafter{\somecontrolseq}), which again solves the problem of the ...


5

TeX doesn't expand tokens when it's absorbing arguments to a macro. So \foo finds } when still looking for its second argument after having decided that \x is the first one. If your aim is to have the second argument to \foo delimited by a space you should do \def\foo#1#2 {% \if#1a% \message{#2} \fi} \def\x{abc } \edef\y{\expandafter\foo\x} \y so ...


4

I’m adding this answer only to justify my assertion that the present question is “somehow related” to How can I check whether two control sequences have the same name? (see the comments). Werner’s solution is great, but it has a slight drawback and a characteristic that, depending on what you want to do, can turn out to be a useful feature, or not. The ...


3

If you just use \insertdate and \inserttitle, you don't need \expandafter, because \MakeUppercase does full (protected) expansion on its argument. However, \inserttitle is quite different from the other two macros. Indeed, \insertdate expands to \today (in general to the argument given to \date) and, similarly, \inserttitle expands to the argument given to ...


3

If you comment out \exp_args:No \msg_term:n { \sean_get:Nn \l_tmpa_prop { key } } you'll see that the error isn't from the definition, but from the fact that the argument to \msg_term:n isn't fully expandable. If you change that line to \exp_args:No \tl_show:n { \sean_get:Nn \l_tmpa_prop { key } } you get: > \cs_set:Nn \obj_this:n {\prop_item:Nn ...


3

If the containment macro doesn't do anything special (that would survive a group), you can set the contents in a box. This allows you to test for something without anything being printed: true false \documentclass{article} \def\somecontrolseq{\macro{silly} text} \def\macro#1{some #1} \newif\ifmacroexists % ...



Only top voted, non community-wiki answers of a minimum length are eligible