# Tag Info

2

% defining a command of 5 arguments not allowed to have pararaph ends. \newcommand*{\cventry}[5]{% % probably missing \par here \vspace{-2.0mm}% negative space, missing % here \setlength\tabcolsep{0pt}% set tabular spacing to 0, missing % here \setlength{\extrarowheight}{0pt}% set extra vertical tabular spacing to 0, missing % here % two column ...

1

I'd use a different approach, namely to just list the symbols we want to make a table of and let TeX do the splitting. The trailing optional argument (default 4) is for the number of pairs of columns; the first optional argument is for a title. \documentclass{article} \usepackage{amsmath,amssymb,booktabs} \usepackage{xparse} \ExplSyntaxOn \...

2

You want to append the period only if a period does not follow (with a possible {} in between) and if a period doesn't follow, there should also be \@. \documentclass{article} \makeatletter \DeclareRobustCommand{\appendperiod}{% \futurelet\next\append@period } \newcommand\append@period{% \if\noexpand\next\bgroup \expandafter\@firstoftwo \else \...

3

This sort of thing has a nasty habit of going wrong when the macro appears in a situation that has not been considered (there always seems to be at least one). Still... \documentclass{article} \makeatletter \newcommand\aname{Some Co\@ifnextchar{.}{}{.\ }} \makeatother \begin{document} I enjoy working at \aname. I really do. She worked at \aname for 5 years. ...

0

The \isFileEmpty-test in your example seems to be intended to put into a box the things that got caught as a macro and to measure the width of that box and in case of that width being 0 to "assume" emptiness. Such a test can be fooled/outmanoeuvred, e.g., by placing overfull boxes of depth/height/width 0pt containing displayable content: \...

3

The problem is that at the beginning of table cells, TeX is expanding tokens looking for \omit or \span (for \multicolumn and such), so it expands \ne to \protect\ne␣, and \protect is \relax which (is not expandable so) is left alone and only then the table template is inserted with \collectcell\showSymbol, but at this point \ne is already expanded. There ...

2

Not really easy, because we need to take care of the possible overshoot of the subscript. \documentclass{article} \usepackage{xparse,amsmath} \DeclareMathOperator*{\emaxop}{emax} \NewDocumentCommand{\emax}{oe{_}}{% \IfNoValueTF{#2} {\emaxop\nolimits\IfValueT{#1}{^{#1}}} {\IfNoValueTF{#1}{\emaxop_{#2}}{\emaxcomplex{#1}{#2}}}% } \makeatletter \...

3

With etoolbox: \documentclass[a4paper]{letter} \usepackage{etoolbox} \newcommand{\stuffing}[2][]{\ensuremath{W_{\mathtt{#2}}\ifblank{#1}{}{^{^{\left[#1\right]}}}}} \begin{document} what I want: $W_\mathtt{a}$ and \stuffing[5]{a} and what I get: \stuffing{a} and \stuffing[5]{a} \end{document}

4

You want to test whether the optional argument is empty or not: \documentclass[a4paper]{article} \newcommand{\stuffing}[2][]{% W_{\mathtt{#2}}% \if\relax\detokenize{#1}\relax \else ^{^{[#1]}}% \fi } \begin{document} what I want: $W_\mathtt{a}$ and $\stuffing[5]{a}$ but what I get: $\stuffing{a}$ and $\stuffing[5]{a}$ \end{document} I removed \...

2

I don't see in the manual any way to use variables in an expandable way and you need the value, not the container. \documentclass[paper=letter,pagesize,UScommercial9]{scrlttr2} %%%%% Goes in a separate package %%%%% \makeatletter \def\@envelopes{} \AtEndLetter{% \begingroup\edef\x{\endgroup \noexpand\g@addto@macro\noexpand\@envelopes{% \...

0

You can override the internal printing function but this will surely bring other problems with it. In particular this is not future-proof, since any name starting with double underscore (__) may change or disappear without notice at any point. \documentclass{article} \usepackage{xfp} \ExplSyntaxOn \cs_set:Npn \__fp_to_decimal_large:Nnnw #1#2#3#4; { \...

3

\documentclass{article} \ExplSyntaxOn \cs_new:Npn \mich_convert_tocomma:n #1 { \exp_args:Ne \tl_to_str:n { \str_map_function:nN {#1} \__mich_convert_tocomma:n } } \cs_new:Npn \__mich_convert_tocomma:n #1 { \int_compare:nNnTF { #1 } = { . } { , } { #1 } } \cs_generate_variant:Nn \mich_convert_tocomma:n {...

3

You can define new meta keys: \documentclass{article} \usepackage{todonotes} \makeatletter \define@key{todonotes}{AK}[]{% \setkeys{todonotes}{author=AK,color=green}}% \makeatother \begin{document} blub\todo[AK]{something} \end{document}

2

With expl3: \documentclass{article} \ExplSyntaxOn \cs_new_protected:Npn \doublehashes #1 #2 { \tl_set_eq:NN \l_tmpa_tl #2 \regex_replace_all:nnN { \cP. } { \cP\#\cP\# } \l_tmpa_tl \tl_set_eq:NN #1 \l_tmpa_tl } \ExplSyntaxOff \def\macro{This is some hashes: ####} \doublehashes\Macro\macro \frenchspacing \begin{document} \texttt{\string\macro=\...

4

Each \def...{body} reduces the number of hash characters to half in its internal representation in the body. Each \toks<num>={body} keeps the number of hash characters. Each \write or \scantokens doubles the number of hash characters. \def\macro{This is some hashes: ##} % we have one # in internal representation \scantokens\expandafter{\expandafter\...

2

You can use \edef with \unexpanded: \documentclass{article} \de\documentclass{article} \def\safedef#1#2{\edef#1{\unexpanded{#2}}} \begin{document} \def\macro{This is some hashes: ##} \safedef\Macro{This is some hashes: ##} \typeout{\macro -\Macro} \end{document} shows This is some hashes: ##-This is some hashes: ####

2

An l3regex approach: \regex_replace_all:nnN { (\cP\#)+ } { \1\1 } \macro A full example: \documentclass{article} \begin{document} \ExplSyntaxOn \tl_new:N \macro \tl_set:Nn \macro {\def\y{\def\z##1{<##1>}}} % before doubling the hash mark \cs_generate_variant:Nn \cs_new:Npn {Npo} \macro \y \z{abc} % output "<abc>" \par % after ...

1

David Carlisle already proposed passing (via \expandafter) the toplevel-expansion of \fragment to an auxiliary macro called \helper. The purpose of this auxiliary macro is rather specific. A more general variation of this approach is combining usage of \expandafter (for obtaining \fragment's toplevel-expansion) with usage of a macro \exchange which does ...

1

There is \@ifpackageloaded \documentclass{article} % \usepackage{color} \makeatletter \@ifpackageloaded{color}{\AtBeginDocument{% {\color{red}Package color already used}\end{document}}}% {\usepackage{color}} \makeatother \begin{document} Some \color{blue} blue color \end{document} You can also test the options of the package with \@ifpackagewithand the ...

1

Sorry, but \patchcommand is not the best tool for the job. Not knowing your real situation, I'll solve the problem you show. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\iterations}{mm} {% #1 = text, #2 = number of iterations \fiat_iteration:nn { #1 } { #2 } } \tl_new:N \l__fiat_iteration_in_tl \tl_new:N \...

1


3

REVISED, based on comment. \documentclass[fleqn]{article} \usepackage{amsmath,pict2e,graphicx} \usepackage{iftex} \ifTUTeX \usepackage{unicode-math} \setmainfont{TeX Gyre Termes}[Scale=1.0] \setmathfont{TeX Gyre Termes Math} \else \usepackage{newtxtext,newtxmath} \fi \makeatletter \newcommand{\my@big}[2][1]{% \mathop{\vphantom{\sum}\def\...

1

This might be a start. It still has a few rough edges, such as the footnote marks. Save as urdu-lbd.sty: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% urdu.style: Basic stylesheet to set up a document primarily in Urdu. %% Copyright © 2020 Loren B. Davis. ALL RIGHTS RESERVED. %% %% This software is hereby released under ...

4

Macros in PGF foreach loops are only expanded once but \printKW needs two steps to expand to the list. The can be fixed for all instances of the foreach loop by patching the internal macros. Here I introduce a check whether the macro is expandable and if it is perform a full expansion (expl3 f-type) on it. You also want \makeatletter ... \makeatother ...

3

You can do it with xparse. The e argument type takes a list of tokens and in the body #1 refers to the item after the first token, #2 to the item after the second token and so on. You can test whether they are present with \IfValueT. I'd not add the \, thin space. If you prefer, add it in the following code. \documentclass{article} \usepackage{amsmath,xparse}...

0

Thats an MWE of how I use it. (mostly in german) \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{hyperref} % optional \usepackage[acronym,toc,shortcuts,xindy,section=section]{glossaries} \makenoidxglossaries \usepackage{xparse} % #1 = optional newglossaryentry value % #2 = optional newacronym parameter % #3 = label % #4 = short form % #5 = ...

1

Here is a plain TeX solution for Polish (modulo calculation based on this answer). Developing similar macros for other Slavic languages is left as an exercise for the reader. \newcount\moduloResult \def\modulo#1#2{% \moduloResult=#1 \divide\moduloResult by #2 \multiply\moduloResult by -#2 \advance\moduloResult by #1\relax} \def\pluralizePOL#1#2#3#4{%...

6

The macro \@fileswithoptions is also used to load class files. Indeed, you find \def\LoadClass{% \ifx\@currext\@pkgextension \@latex@error {\noexpand\LoadClass in package file}% {You may only use \noexpand\LoadClass in a class file.}% \fi \@fileswithoptions\@clsextension} As usual for macros with optional arguments, the arguments are ...

2

The first argument is going to be \@pkgextension Interestingly, unless you've deleted some lines in the definition of \@fileswith@pti@ns, that first argument isn't actually used anywhere.

0

This is an easy task using the expkv-cs package as it is fully expandable (so doesn't care for the implicit group added at & as it doesn't need any definitions which could be limited by that scope) and can split a key=value argument into several numbered parameters. One can define a new splitting macro with \ekvcSplit\tabularEntry{a=,b=}{#1&#2} This ...

1

1

Starting with version 0.4 (released on 2020-07-04) of expkv-def one can define an action for an unknown choice (and since a boolTF key is internally the same as a choice key with the choices true and false and appropriate actions we can use the unknown-choice prefix for map). This can be used to define an action which we can use to set the text key of pgf (I'...

2

The manual of the aliascnt-package says: 1.2 Syntax Macro names in user land contain the package name aliascnt in order to prevent name clashes. \newaliascnt{⟨ALIASCNT⟩}{⟨BASECNT⟩} An alias counter ⟨ALIASCNT⟩ is created that does not allocate a new TeX counter register. It shares the count register and the clear list with counter ⟨BASECNT⟩. If the value of ...

5

Using expkv There are different ways on how to achieve this with expkv and related packages which I present in the following. Only expkv The main package of expkv does only provide a very low level interface comparable to the widely known keyval package. You can define new keys with \ekvdef and there are no predefined handlers doing your job. For instance to ...

5

The input \sqrt\frac12 only works by chance. The macro \sqrt is basicelly defined as \@ifnextchar[\@sqrt\sqrtsign Since no [ follows the call, you get \sqrtsign\frac12 and then \radical "270370\relax\frac12 Now TeX wants to see to what \radical applies to and it happens to be \frac12 that expands to {\begingroup 1\endgroup\over 2} and the braces ...

10


1

The macro \ifstrequal does no expansion to its arguments. One could define a new one that does, but it's probably better to avoid heavy nesting with the help of expl3. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewExpandableDocumentCommand{\fixsmpl}{m} { \str_case_e:nVF { #1 } \c_dagfinn_fixsmpl_tl { \PackageError{fixsmpl}{...

1

Comments in the code... \documentclass[a4paper]{article} \usepackage{pgfkeys} %no need to full-load tikz \pgfkeys{%/tikz/.cd, you want your top-family, no? % /map/.is family, % /map/.cd, %<-added .cd why? /map/.is choice, % /map/.default=false, % not useful in choices, you have to call one of them anyway /map/true/.code={S1 S2 S3},...

1

It seems to me that you don't want to evaluate map at all if stepstrokes is true, because the output of stepstrokes does already include the output of map. The following does this by putting the test of \mymapTF inside the false branch of \mystepstrokesTF: \documentclass{article} \usepackage{verbatimbox} \usepackage{tikz} %\usepackage{xcolor} \usepackage{...

1

You might be interested in Dr. Nicola Talbot's datatool-package for maintaining databases and for iterating on elements of records of databases. Examples on how to approach the matter using the datatool-package are at the end of this answer. Be that as it may. \csname..\endcsname might be your friend: \documentclass{article} \usepackage{tikz} \begin{...

3


1


1

If you have a lot of that kind of figures, then the knot package should be used. The following is another suggestion. I draw by hand each curve and put some nodes in appropriate position. Code is explained itself (I hope!). \documentclass[tikz,border=5mm]{standalone} \begin{document} \begin{tikzpicture} \def\rcurv{(1,0)--++(90:1) arc(180:0:.5) arc(180:360:....

4

For the MWE as given it is sufficient to first expand the \colorGet macro into a temporary command and then use that as argument for \definecolor. The solution may need to be expanded (pun intended...) if xstring is used for the \colorGet macro. \documentclass{article} \usepackage{xcolor} \newcommand{\colorGet}[2]{D3523C} % A macro which returns a different ...

4

Here's an expandable expl3 implementation that copes with middle names, single names, and no forbidden characters :-) \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \seq_new:N \g_brasil_name_seq \NewDocumentCommand \WhatIsYourName { m } { \seq_gset_split:Nnn \g_brasil_name_seq { ~ } {#1} } \NewExpandableDocumentCommand \MyNameIs { } { \...

3

One way to achieve this is by specifying the "shape" of the input using \def. For example, if you define \def\@setinitials#1#2@{\def\@initials{#1}} and then use \@setinitials Joaquim@ then when \@setinitials is expanded #1 is set to J and #2 to oaquim so that \@initials is defined to be J. The key point is that the @ at the end of the parameter ...

0

Update: I ended up just using a python script that searches for nested parenthesis and replaces it with \left, \right. I used \pr for parenthesis in my case. tex = re.sub(r"$$([^()\n]*?)\((.*?)$$([^()\n]*?)\)", r"\\pr{\1(\2)\3}", tex)

1

I want to add another solution, because a negative \delimtershortfall can look a bit unpleasant. What I do is declaring a parenthis-function that uses \vphantom with \raisebox to add extra height to the outer delimiter. The solution is not pretty: I use \mathop because else \vphantom does not work and then add negative space to counter the extra space that \...

2

There are a few problems with your attempt. First problem: you're doing the computations in a table cell, so the results are forgotten as the cell ends. This can be fixed by “globalizing” the variables containing the totals. Second problem: you need to expand the variables before passing the row to the table scanner. Third issue: tabularx processes the ...

1

I suggest a simpler way to do the job: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\dummy}{mO{;}mm} { \cs_new:cpx { #4 } { \exp_not:n { #3 } \prg_replicate:nn { #1 - 1 } { \exp_not:n { #2 #3 } } } } \ExplSyntaxOff \begin{document} \dummy{5}{M}{varSpec} \dummy{3}[\textit{\&}]{\textbf{a}}{varBf} \...

Top 50 recent answers are included