7

The \unexpanded primitive is essentially an anonymous toks, which means no expansion _within an \edef or similar, whereas \noexpand explicitly changes the behaviour of the next token to be equal to \relax for one expansion. This is perhaps easier to see if we choose to typeset the results of the two: \documentclass{article} \begin{document} \newcommand{\...


6

Detach the first conditional. \documentclass{article} \newcount\zNonZero \def\zLoop#1{% \zNonZero=1 \zLoopStart{#1}% \zLoopLoop{#1}% } \def\zLoopStart#1{% \ifnum#1<1 % HOW TO CHECK THIS ONLY ONCE? \zNonZero=0 \fi } \def\zLoopLoop#1{% \ifnum#1<5 #1...(\the\zNonZero)\par \zNonZero=1 \expandafter\zLoopLoop\expandafter{\the\...


5

The code became a tad long. Much longer than I initially thought it would be. Your conditions aren't too clear, I think. What I implemented (in crappy pseudocode) is: procedure cur_char // (a, b, c, or d) if next_char is lowercase_vowel print replacement (cur_char) // replaces ABCD by PQRS else if next_char is uppercase_X ...


4

\ifx compares two tokens without expansion, so if you pass [ ] to \bpdef, the \ifx test will compare [ with a space and fail. You need to define a temporary macro and compare it with \bptoks. Alternatively you can use \pdfstrcmp (or the equivalent in other engines (\pdf@strcmp if you load pdftexcmds)) to make a string comparison: \documentclass{article} \...


3

\documentclass{article} \begin{document} \begingroup \catcode`L=\active \catcode`M=\active \catcode`N=\active \makeatletter \def L{\@ifnextchar p{q\@gobble}{}} \def M{\@ifnextchar p{r\@gobble}{}} \def N{\@ifnextchar p{s\@gobble}{}} \makeatother Lp Lq Lr Mp Mq Mr Np Nq Nr \endgroup Lp Lq Lr Mp Mq Mr Np Nq Nr \end{document}


3

You have several spaces inserted by newlines... \newcommand{\vs}[2]{% \relax\ifmmode \ifemptyarg{#2}% {#1\text{-vector space}}% {#1\text{-vector space }#2}% \else \ifemptyarg{#2}% {$#1$-vector space}% {$#1$-vector space $#2$}% \fi} works. Notice that the "%" after the \ifemptyarg{#2} is not ...


3

You can hook into the definition of the wide option and make your conditional true. The value of the conditional is reset after the environment. Note also that the wide option takes an argument. If you pass none, then \parindent is used (i.e., \begin{itemize}[wide] is the same as \begin{itemize}[wide=\parindent]). However you should not try to change ...


2

Here is a way you could use list styles, contained in macro settings. \documentclass{article} \usepackage{enumitem,lipsum} \newenvironment{styledlist}[1][] {\expandafter\itemize\expandafter[#1]}{\enditemize} \def\widelist{wide,itemindent=15pt,label=*,leftmargin=-1cm,rightmargin=-1cm} \def\narrowlist{itemindent=15pt,label=++,leftmargin=1cm,rightmargin=1cm} ...


2

The posted code does set the path conditionally, the test file below shows both settings: LaTeX2e <2018-12-01> (/usr/local/texlive/2019/texmf-dist/tex/latex/base/ifthen.sty) > \input@path=macro: ->{"../folder-1/"}. l.13 \show\input@path ? > \input@path=macro: ->{"../folder-2/"}. l.26 \show\input@path ? ) No pages of output. \...


2

As I don't have the right fonts available on my system, this is kind of a shot in the dark. The idea is to have nested \ifx checks, like the following structure: \ifx\tmp X \else \ifx\tmp Y \else \fi \fi Because you are using \@gobble to remove the following token from the input stream, you have to be a bit more careful, because TeX leaves parts of ...


2

The command \solutions just switches the conditional \if@solutions, but cannot change already executed code. And \excludecomment{solution} has been performed. The class should do \excludecomment{solution} \newcommand{\solutions}{\renewenvironment{solution}{\textbf{L\"osung:}\\}{}}


2

As too long for a comment: The problem probably is that \ifthenelse is not fully expandable. What might work is to execute the test, storing the new option in a macro, and then adding the option in an \edef: \def\myopt{} \ifthenelse{\boolean{myDraft}}{\def\myopt{3Dmenu}}{} \edef\temp{\unexpanded{ \includemedia[ width=1\linewidth, height=0.56\...


2

If I correctly understood your needs, the following should do what you want: \documentclass{article} \usepackage{datatool} \usepackage[strict]{changepage} \usepackage{filecontents} \usepackage{tcolorbox} \usepackage[absolute,overlay]{textpos} \usepackage{xcolor} \usepackage{xparse} \begin{filecontents*}{test1.csv} Acol, Bcol,Ccol Ax,Bx,1 Ay,By,3 A1,B22,1 ...


2

\documentclass{article} \begin{document} \parindent0pt \newcount\zNonZero \newif\ifCheck \Checktrue \def\zLoop#1{% \zNonZero1 \ifCheck\ifnum#1<1 \zNonZero0 \fi\Checkfalse\fi \ifnum#1<5 #1...(\the\zNonZero)\newline \expandafter\zLoop\expandafter{\the\numexpr#1+1\relax} \fi \...


1

(This is part 2 of my answer which consists of two parts. Here is a link to part 1 of my answer.) By now the tokens that are to be delivered in the different cases were "hardwired" in the macro-definition. But you can combine such delimited-argument-based forking-mechanisms with mechanisms for grabbing the k-th element of a list of undelimited arguments ...


1

(This is part 1 of my answer which consists of two parts. Here is a link to part 2 of my answer.) You can implement such testing by means of delimited arguments also. With tests based only on delimited arguments, no \if-switches are applied, thus such tests cannot be fooled by unbalanced \else or \fi or \endcsname and the like. With tests based only on ...


1

@siracusa suggested the right way of formatting my code and now I've this, which is fully ready. \documentclass{article} \usepackage{fontspec} \setmainfont{Sanskrit 2003} %Any Devanagari font. \newfontfamily{\doulo}{Doulos SIL} \setlength{\parindent}{0cm} \makeatletter \def\ifischar#1{% \ifx\tmp#1% \expandafter\@firstoftwo \else \...


1

Using \futurelet you can crank out the cases of the following token being { or } or a space-token. If the following token is none of these tokens, you can have LaTeX process it as macro-argument. Macro-arguments in turn can be examined in various ways. One way of interpreting your vague specifications is: \documentclass{article} \makeatletter \newcommand\...


1

You can use something like this: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \tl_new:N \g_makkototo_printbibliography_opts_tl \cs_new_protected:Npn \makkototo_printbibliography:n #1 { % Call the original \printbibliography command \__makkototo_printbibliography_orig [#1] } \cs_generate_variant:Nn \makkototo_printbibliography:n {...


1

I'd like to present another solution that is able to parse integer and floating point numbers. Usage of the main macro is \ifnumber[<optional setup>]{<tokens>}{<true part>}{<false part>} where <tokens> is the string to be tested whether it represents a number. <optional setup> is an optional list of definitions to modify ...


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