5
votes
1answer
210 views

Can a \newcommand Definition Contain Braces as Substitution Text?

The following example is completely counter-intuitive, but I need this in a bigger definition I'm not including here. \newcommand{\openbrace}{{} I need this to start a nested scope. Is this ...
5
votes
2answers
116 views

Whole word as a macro argument when macro called without braces

I have a macro: \newcommand{\sEmph}[1]{\textbf{\textcolor{NavyBlue}{#1}}} Then I can do: Some text is in \sEmph{blue}, and some in black. with this result: But if I omit the braces only the ...
4
votes
0answers
63 views

Should I put the name of a new command in braces? [duplicate]

Possible Duplicate: Why do people use unnecessary braces? In so far as I know, the open and close braces around the command name for \newcommand{\commandname}{...} versus ...
6
votes
3answers
119 views

How do I handle a closing brace in a 'character scanning' macro?

Problem I need to define a command that grabs all numerical digits following it and leaves the rest alone. Eventually I came up with this: First Solution \RequirePackage{xstring} % for \IfInteger ...
1
vote
1answer
258 views

How to strip curly-braces from variable before using it as a filename?

I'm trying to use a variable to pass a filename to \includegraphics. I'm having trouble because my filename is built up from other variables. This leaves an empty curly-brace inside the filename. The ...
4
votes
1answer
461 views

lstinline loses braces when used as an argument to another command

I'm using the listings package, for the Java language (which, as all C-like languages, uses braces as a block delimiter). I intend to use \lstinline{...} as the second argument to a command for ...
2
votes
1answer
505 views

Unbalanced braces with newenvironment / NewEnviron + Command

This is a follow-up question of my Unbalanced braces with newenvironment / NewEnviron post. The gist is that by using \NewEnviron{myEnv}{% ...
2
votes
1answer
450 views

Unbalanced braces with newenvironment / NewEnviron

I am trying to define an Environment myEnv s.t. \begin{myEnv} text1 \end{myEnv} text2} expands to \renewcommand{\myCommand}{ text1 } { text2} The reason for the obviously unbalanced expression ...
20
votes
3answers
1k views

Why does TeX remove braces around delimited arguments?

On pp. 203–204 of the TeXbook, Knuth describes how TeX absorbs macros' arguments: delimited go until the first appearance of the delimiter, and undelimited go until the next token, in both cases ...
5
votes
1answer
288 views

Nested macro envocation - syntax error?

I get a Argument of \\drs has an extra }. when I try to process the following: \documentclass{article} \usepackage{tikz} \newcommand{\drs}[2][lambda/.initial={}]{% \{% {\pgfkeys{/drs/.cd, #1, ...
34
votes
8answers
2k views

Why do people use unnecessary braces?

I often see people creating new macros where the macro token is surrounded by braces. For example, \newcommand{\foo}{foo} This is unnecessary and I find the extra braces make it harder to read. Why ...