# Tag Info

7

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 ...

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 ...

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 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 % ...

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 ...

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 ...

Top 50 recent answers are included