# Tag Info

7

\sindex, like \index expands no macro by design, unless it's called as argument to another command. However, your \rmBrcs command doesn't work purely by expansion, in particular \StrDel is not performed during a \write operation, so you don't get what you want anyway with the trick \newcommand{\Sindex}[2][]{\sindex[#1]{#2}} or similar. You have to take ...

4

This is the usual \verb not working in an argument problem. \obeyspaces changes the catcode of space which means that a space character in a file is converted to an active token. catcode changes have no effect on tokens already created. In your case the entire argument of \newcommand has been tokenized and so there is no space token at all after \def it is ...

4

Periods are a strange beast, because the space factor must be set correctly (of course, if you use \nonfrenchspacing). \catcode@=11 \def\checkperiod{\futurelet\next\check@period} \def\check@period{% \if\noexpand\next.% \spacefactor\sfcode. \expandafter\@gobble \fi} \long\def\@gobble#1{} \def\@{\spacefactor\@m} \catcode`@=12 \xspaceskip=4em % ...

4

I wouldn't advice this, but this works (without any warranty) \documentclass{article} \usepackage{amsmath,amssymb} \newenvironment{proof}% {\textbf{Proof:}}% {\hfill$\blacksquare$} \def\pf#1{\begin{proof} #1 \end{proof}} \begin{document} \pf{some proof here} \end{document} It is better to use amsthm and its environments for proof etc. to use ...

4

I very strongly recommend not doing this. However, it is probably not as bad as what you've done for align so, if you must: \documentclass{article} \usepackage{xparse,amssymb} \NewDocumentCommand \pf { +r[] } {% \noindent\textbf{Proof:} #1\hspace*{\fill}\nolinebreak$\blacksquare$} \begin{document} \pf[ Alice saw Nobody on the road, whereas the ...

3

This should be the right definition for your command \qweq: \newcommand{\qweq}[4][!htbp]{% \begin{figure}[#1]% \centering% \includegraphics[width=9cm]{/images/task#2/#3}% \caption{\emph{\small{#4}}}% \end{figure}% } Note, first of all, that each line is ended by % to avoid spurious spaces (especially in the caption...). Moreover a fourth optional argument ...

3

I don't know if this was your intend by I try it: \long\def\isnextchar#1#2#3{\def\tmpa{#2}\def\tmpb{#3}% \let\tmp=#1\futurelet\next\isnextcharA } \def\isnextcharA{\ifx\tmp\next\expandafter\tmpa\else\expandafter\tmpb\fi} \def\PhD{\isnextchar.{PhD}{Ph.D.}} \def\PhD{\isnextchar.{PhD}{Ph.D.}} The \PhD\ inside the sentence is different than \PhD. gives: The ...

3

As I indicated in my comment, you can dispense with the counters. Just use the \def as an argument. If you need a more complex calculation, you can use \numexpr, as in my 2nd example. \documentclass{article} \begin{document} \def\temp{1} \def\X{2} \ifnum\temp>0 Yea! \else Boo! \fi \ifnum\numexpr\temp-\X\relax>0 Yea! \else Boo! \fi \end{document} ...

3


2

You need to define \rmbrcs as expand-only macro: \def\rmbrcs#1{\expandafter\rmbrcsA#1()\end} \def\rmbrcsA#1(#2)#3\end{\ifx\end#3\end #1\else \rmbrcsA#1#2#3\end\fi} There is no need to worry about tail recursion (dangling \fi) as the argument here will be simple text not some recursive thing.

2

I used Werner's comment for the $...$ form, but added forms that work for equation and align. EDITED to handle the OP's requirements: 1) arguments to \mathmacro; 2) multiple calls to \mathmacro in a single environment; 3) works when embedded within \ensuremath argument. REVISED SOLUTION (can handle multiple \mathmacro calls) In this approach, to allow ...

2

This may have the drawback of slightly affecting line spacing, but... I substitute \Overline which does an \overline with a little extra stack gap added. And for \preclosure, I modified it so that it preserves the math style of the argument, using the \ThisStyle{...\SavedStyle...} construct of the scalerel package. I did not really address the issue of ...

1

This solution requires a recently updated TeX distribution. It has the advantage, over the approach with \obeyspaces, that no category code is changed, so the macro can also go in the argument to other commands. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\capitalize}{m} { \ruben_capitalize:n { #1 } } \seq_new:N ...

1

For namely this purpose (\capitalize) I prefer to not use active space but to separate the parameter into words. The reason is that user can type more than only one space between words, the end of line is interpreted by token processor as a space etc. So, my suggestion is: \def\capitalize#1{\def\tmp{}\capitalizeA#1 {} } \def\capitalizeA#1 ...

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