# Tag Info

9

\expandafter doesn't expand everything after it, just the following token. Also, since it seems like b@counter measures the content added to \b@toks, I don't see the need for \ifnum... \else\b@toks=\expandafter{\the\b@toks (\the\a@toks) } \fi where you want to add (an empty) \b@toks to itself. The following produces what you're after, I think (I've ...

7

If I understand correctly, you want to use the relative positions of the saved nodes in your new picture. That is, each node should refer to a position in the new picture relative to the new origin. Here's some code that saves all the data for a list of specified nodes which can then be restored at a later time in the document. It uses LaTeX3 stuff ...

6

If I see given "user environment" (last twelve lines in your code) and desired output, then I can say: it is very simple to do it at TeX primitive level: \def\alist{}\def\plist{} \def\Aa#1{\edef\alist{\alist,\detokenize{#1}}} \def\Af{\edef\plist{\ifx\plist\empty\else\plist, \fi (\ifx\alist\empty\else\expandafter\applyand\alist,,\fi)}% ...

5

Werner's analysis is very good. Here's an alternative implementation with xparse and expl3. Note that you can define as optional argument to \print the separator between items (default is “comma-space”). \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\aAdd}{m} { \mapo_aadd:n { #1 } } \NewDocumentCommand{\bexp}{} { ...

4

I now see from your other questions that, despite your comments concerning how easy it is to do this in modern programming languages, you are determined to compare those languages with TeX, rejecting the modern interfaces which build upon it. Little wonder, then, that the TeX case seems more difficult. For a fair comparison, you need to compare other ...

4

Define \UnitLabel with an argument: \documentclass{article} \usepackage{lipsum} \usepackage{xparse} \newcounter{Unit} \NewDocumentCommand{\UnitLabel}{m}{% \makebox[4.5em][l]{Unit #1}% } \NewDocumentCommand{\Unit}{ m }{% \refstepcounter{Unit}% \section*{\UnitLabel{\Roman{Unit}}#1} \addcontentsline{toc}{section}{\UnitLabel{\Roman{Unit}}#1}% } ...

3

The important thing in the application you seem to have in mind is not forcing a too rigid setting. Thus I store each authors' list as itself, but as the argument to another command, which can be set at usage time in a variety of ways. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\addauthors}{m} { \mapo_addauthors:n { ...

3

Use \DeclareExpandableDocumentCommand -- this does not allow an optional argument at the end of the argument list, but this is no issue here! The \NewDocumentCommand version isn't expandable, see e.g. \show\UnitLabel: \UnitLabel=\protected macro: ->\makebox [4.5em][l]{Unit \Roman {Unit}}. l.25 \show\UnitLabel i.e. \UnitLabel is protected. The xparse ...

2

I admit I don't fully understand what you're trying to do here, but as egreg notes, \begin and \item are fragile which is what's causing the problem. It's easy enough to "fix" this particular example \newcommand{\wrapper}[1]{% \test{% \begingroup \let\begin\relax \let\item\relax \let\end\relax \protected@edef\x{% ...

2

I am unclear on the detailed behavior desired, but... Is this what is desired? \documentclass{article} \usepackage{xpatch} \newcommand\app[1]{\textbf{#1}} % <- #1 is appended's macro's parameter \def\addtoapp#1{% \apptocmd{\app}{#1}{}{} % <- passing appended macro's parameter to appended macro again } \begin{document} \app{Food App} \addtoapp{This ...

2

Because some times we like to reinvent the wheel. Here is a an approach that allows you to alter the format on the fly among other things. \documentclass{article} \usepackage{etoolbox} \usepackage[T1]{fontenc} \usepackage{lmodern} \makeatletter %% ----------------------- %% %% --- Defining a list --- %% ...

2

I think this is what you want: \documentclass{article} \usepackage{xparse} \usepackage{hyperref} \DeclareExpandableDocumentCommand{\foo}{smm}{% \texorpdfstring {\IfBooleanTF{#1}{\textsf}{\textit}{#2}--#3} {#2-#3}% } \begin{document} \section{This is \foo{A}{B}} \section{This is \foo*{A}{B}} \end{document}

2

Your errore was that the column type for tabularx is X, not x. I simplified you code, loading xcolor with option table (which loads colortbl in that case) and using the \rowcolors command. Also, I loaded the boldline package, to have variable thickness rules, and gave some vertical padding with \arraystretch: \documentclass{article} ...

1

The best alternative is of course expl3: \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\NewPoints}{m} { \clist_map_inline:nn { #1 } { \cs_set:cpx { ##1 } { a-\NumNode-\theLittNode } \stepcounter{LittNode} } } \ExplSyntaxOff

1

Full customizable and human readable node names with no interaction between different macros. \documentclass{article} \usepackage{tikz} \usetikzlibrary{quotes} \makeatletter \newcommand{\NewPoints}[1]{% \expandafter\edef\csname #1\endcsname{% a-\NumNode-\theLittNode} \stepcounter{LittNode} %} } \makeatother % counter for naming nodes ...

1

\apptocmd doesn't like to be in the argument to another command when # is involved. You can do it with a conditional: \documentclass{article} \usepackage{etoolbox} \newcommand\app[1]{\textbf{#1}} \newif\ifdebugmode \debugmodetrue % comment for not applying the patches \ifdebugmode \newwrite\appfile ...

1

Another approach is to create a stack that contains the nodes for a macros. Each call to a macro create en new level in the stack, and the level is deleted at the end of the macro. One can preserve the nodes one chooses by picking them, and only ones that are useful for the future. One declares some nodes (human readable names) at the beginning of the ...

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