# How do extra braces impact the placement of items in the document?

I am placing some of my document through some outside BASH scripts, but want to protect some information such that the scripts will not change them. The simplest option for me is to put { and } around important areas and let the BASH script know it should ignore these parts.

• The { and } always appear within the same sentence and never span two or more sentences.
• Sometimes { and } must be placed within math mode environments or surround macros.

As best as I can tell, when { and } are placed within parts of a sentence or within math mode, they are invisible when compiled. Is this really so? Could this change things, such as the spacing between words, the line-breaking of sentences, or the appearance of text?

• Do extra { and }'s really have no effect?
• Are there any characters I could put in the document which xelatex will completely ignore?
-

{} in the middle of a word might block kerning: compare AV and A{}V. (As David Kastrup point out, the empty group can do nothing if TeX tries hyphenation on the word where's the empty group.) On the other hand, putting group of words inside braces in a paragraph doesn't do anything; of course, assignments made inside the braces won't survive outside them.

On the contrary, in math mode a braced group produces a subformula which is then treated as a single object (an ordinary atom, to be precise). In this respect, however, braced arguments to commands don't count as braced groups.

It is quite different to type $a+b$ and $a{+}b$: in the former, + is a binary operation symbol, in the latter it isn't. There's a subtle difference also between $x=0$ and ${x=0}$. In the latter the symbols are assigned their proper class (= is considered as a relation symbol), but the spaces don't participate to stretching or shrinking with the other spaces in the same line. TeX is not allowed to break the line after the = in the latter formula, while it is in the former (but this is not a good method for forbidding such a break, $x=\nobreak 0$ is better).

An empty group in math mode is not ignored: it's regarded as an ordinary atom, as far as spacing is concerned: compare $-1$ and ${}-1$.

So braced groups in math formulas should be avoided, in general, though they have their uses in particular cases.

What you can do is using some delimiters that are stripped off when passing the information. Alternatively, pick two characters that you're sure you won't use in the TeX file, for instance ⟦ and ⟧, as delimiters for Bash, saying in the preamble of your document

\catcode\⟦=9
\catcode\⟧=9


that will tell XeTeX to ignore those two characters.

-
{}' does not reliably block kerning: if TeX attempts hyphenation in the paragraph, the kerning gets reconstituted. – user9588 Jan 7 '12 at 13:19
@DavidKastrup Thanks for pointing it out; I'll do a rewording. The point is that it may block kerning. – egreg Jan 7 '12 at 13:22

There are areas where inserting braces could cause a difference in the typesetting. However, it may be very dependent on the use of your braces. As such, here are some considerations:

\documentclass{article}
\begin{document}
Here is some {text} that {should {be {left} unaffected} by braces.
In {text mode}, this is not a problem}. In math mode, there may be problems. Compare
$y-2+x\ \textrm{with}\ y{-2+x}.$
It may be a problem with {\TeX\ } since you don't need a control space afterward.
If you use \TeX\ with a control space it works.
\end{document}


A difference in spacing is visible in math mode where - is changed from a binary operator (the first instance) to a unary operator (second instance). Also, the grouping via braces in {\TeX\ } leads to double spacing when compared to \TeX\ . Since you are probably required to use these "don't touch" delimiters in pairs, many (if not all) combinations of non-typeset symbols/control sequences could cause spacing issues.

One alternative could be to write a "verbatim" or "do nothing" macro

\newcommand{\donttouch}[1]{#1}
`

that just typesets it's argument without doing anything. This might force you to typeset the document correctly, yet also allow something to tap into when it comes to parsing the source file.

-