# Tag Info

8

The sequence \renewcommand{\twocolumn}{\twocolumn[{} would define a commmand \twocolumn that - among other things - would call itself. You would get some sort of recursive loop where compilation might terminate with an error message TeX capacity exceeded or the like when during recursion too many opening brackets and opening braces got accumulated. ...

7

You need the command to expand to \multicolumn \documentclass[12pt,border=1mm,preview]{standalone} \usepackage{xparse} \DeclareExpandableDocumentCommand\xmcbf{O{c|}m}{\multicolumn{1}{#1}{\textbf{#2}}} \begin{document} \begin{tabular}{lr} \xmcbf[|c|]{AAA} & \xmcbf{BBB} \\ \hline C & D \\ \hline \end{tabular} ...

5


5

The definition mangling should probably be really constrained to the programming (expl3) layer with just the top level "latex2e" interface defined via xparse \NewDocumentCommand, also it is clearer in l3 if you define the commands first taking a normal \zzzz argument then the \expandafter\...\csname idiom is pre-packaged as "define a c variant" so... ...

4

I hope this is the right thing the O.P. wants to have ... Requesting running numbers, the macro \makeLineNumberRunning is used for typesetting the numbers. The query about the specific line number, say, 5, is easy with \ifnum\value{linenumber} = 5 and using a \raisebox then. The value of the linenumber, the raising and the displayed text can be changed, ...

4

I am not entirely sure that I understood what you want. However, your MWE can easily be achieved with xparse and its v type argument: \documentclass{article} \usepackage{qrcode,xparse} \NewDocumentCommand{\script}{v}{% \texttt{#1} \qrcode{#1}% } \begin{document} \script{test} \script{&$\#$} \end{document} Keep in mind, though, that now since now ...

3

Here is a solution \documentclass{article} \usepackage{xcolor} \begin{document} $\raisebox{\baselineskip}{4)}\frac{1}{2}=\frac{\textcolor{red}{1\cdot4}}{\textcolor{red}{2\cdot4}}=\frac{4}{8}$ $\raisebox{\baselineskip}{4)}\frac{1}{2}=\frac{\textcolor{red}{1\cdot4}}{\textcolor{red}{2\cdot4}}=\frac{4}{8}$ \end{document}

3

As you are doing inside an environment you need to define \counterIDX "globally" by using \gdef: \documentclass{memoir} \usepackage{totcount} \newenvironment{passagequestions}{% This does not work \gdef\counterIDX{passagecounterX}% \newtotcounter{c\counterIDX}% \total{c\counterIDX}% }{% } \begin{document} ...

3

You don't want a command name for the name of an environment. Just the name is fine. So, you can do this: \documentclass{article} \usepackage{amsthm,environ} \renewcommand\newtheorem[2]{% \NewEnviron{#1}[1]{% ##1 : \BODY }% } \begin{document} \newtheorem{acorns}{oaks} \begin{acorns}{trees} leaves and things \end{acorns} \end{document} ...

2

I know that you mentioned expl3 in the title of your post. But we have the TeX primitive language for such things 30 years. \def\sdef#1{\expandafter\def\csname#1\endcsname} \def\foo#1{\sdef{foo#1}{Hello World}} \def\foocall{\foo{start}\foostart} \foocall Why to reinvent the wheel? Why to learn and use a new more complicated language?

2

Maybe you are looking for something like the following example: \long\def\mynewstartcommand#1\endmycommand{% \startcommand[{#1}]\endmycommand } \mynewstartcommand nononononononononononon nononononononononononon nononononononononononon \endmycommand But the question is not too clear, what's the regular content of the argument, what's the purpose ...

2

One possible work around is to use a temporary file. First you need a macro to write to the file (\jobname.tmp was used here) and read it twice using the regular and the listing input commands: \usepackage{listings} \newwrite\tempfile \newcommand{\example}[1]{ \immediate\openout\tempfile=\jobname.tmp \immediate\write\tempfile{#1} ...

1

Why does the following code not work? Let's have a closer look at what \NewEnviron does: After a short macro chain to parse user input properly \NewEnviron uses \env@newenvironment which was \let to \newenvironment in the beginning. Now, \newenvironment internally does among other things (a little simplified) something like \expandafter\def\csname ...

1

With expl3 We check if there's _ inside the argument of \des; if there is no _ inside, we just append _{\textnormal{des}} to the argument of \des; and if there's indeed at least one _, we substitute it by a macro (\riccardo_dessb:n) which in turn, when expanded, takes one argument (the original subscript) and transforms into _{<original ...

1

In order to cope with all the possibilities, you can use regular expressions. The only assumption I make is that no space follows _, but this could be accommodated as well. The name of the functions should be self-explaining. For the syntax of regular expressions, consult texdoc l3regex. \documentclass{article} \usepackage{xparse,l3regex} \ExplSyntaxOn ...

1

Do you perhaps mean something like "highlight" by "amplify"? Anyway, I think \newcommand{\colorfrac}[3][red]{\frac{{\color{#1} #2}}{{\color{#1} #3}}} would suit your purpose. \colorfrac{1}{2} would give a red '1/2' and \colorfrac[green]{1}{3} a green one (needs the color package). Edit As an answer to your comment: Of course you could, ...

1

The interface is already there, just use a c type argument instead of N: \documentclass{article} % Module named foo ;-) \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\foo}{m}{% \cs_new:cn {foo_#1:}{Hello ~ World} } \NewDocumentCommand{\foocall}{}{% \foo{start} % define \foo_start: \foo_start: } \ExplSyntaxOff \begin{document} \foocall ...

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