# A basic issue involving too much space after an exclamation mark followed by a closing parenthesis

Kindly consider this:

here is some (great!) text.


For some reasons, I am experiencing a much greater space between !) and text than between some and (. The latter space is normal. The former space is abnormally large; it looks like a space that appears after a sentence (i.e. after a dot).

How can I fix this issue?

-
Please add a minimal working example (MWE) that illustrates your problem. – percusse Sep 16 '12 at 23:43
You can suppress the extra space using \@ after the exclamation mark. – Guido Sep 16 '12 at 23:51
another way to suppress the extra space is to insert a "slash-space" after the closing paren: (great!)\ text. to my mind (as an unregenerate plain tex devotee) this is preferable to \@ as it is what is proposed in the texbook. \@ also has the meaning of "this is the end of a sentence" when it follows an uppercase letter, and i don't like the ambiguity. – barbara beeton Sep 21 '12 at 20:06
I always thought (great!)\ text was the preferred way to do it in LaTeX, too. At the top of page 15 of Lamport's LaTeX 2e manual, he has Beans (lima, etc.)\ have ... as an example of how to deal with this situation. – MSC Jun 4 '13 at 15:59

\documentclass{article}
\showboxdepth=\maxdimen
\tracingonline=1
\begin{document}
\sbox0{Here is some (great!) text. Another word.}
\usebox0
\scrollmode
\showbox0
\end{document}


The box contents:

> \box0=
\hbox(7.5+2.5)x184.1114
.\OT1/cmr/m/n/10 H
.\OT1/cmr/m/n/10 e
.\OT1/cmr/m/n/10 r
.\OT1/cmr/m/n/10 e
.\glue 3.33333 plus 1.66666 minus 1.11111
.\OT1/cmr/m/n/10 i
.\OT1/cmr/m/n/10 s
.\glue 3.33333 plus 1.66666 minus 1.11111
.\OT1/cmr/m/n/10 s
.\OT1/cmr/m/n/10 o
.\OT1/cmr/m/n/10 m
.\OT1/cmr/m/n/10 e
.\glue 3.33333 plus 1.66666 minus 1.11111
.\OT1/cmr/m/n/10 (
.\OT1/cmr/m/n/10 g
.\OT1/cmr/m/n/10 r
.\OT1/cmr/m/n/10 e
.\OT1/cmr/m/n/10 a
.\OT1/cmr/m/n/10 t
.\OT1/cmr/m/n/10 !
.\OT1/cmr/m/n/10 )
.\glue 4.44444 plus 4.99997 minus 0.37036
.\OT1/cmr/m/n/10 t
.\OT1/cmr/m/n/10 e
.\OT1/cmr/m/n/10 x
.\OT1/cmr/m/n/10 t
.\OT1/cmr/m/n/10 .
.\glue 4.44444 plus 4.99997 minus 0.37036
.\OT1/cmr/m/n/10 A
.\OT1/cmr/m/n/10 n
.\OT1/cmr/m/n/10 o
.\OT1/cmr/m/n/10 t
.\OT1/cmr/m/n/10 h
.\OT1/cmr/m/n/10 e
.\OT1/cmr/m/n/10 r
.\glue 3.33333 plus 1.66666 minus 1.11111
.\OT1/cmr/m/n/10 w
.\kern-0.27779
.\OT1/cmr/m/n/10 o
.\OT1/cmr/m/n/10 r
.\OT1/cmr/m/n/10 d
.\OT1/cmr/m/n/10 .

! OK.
l.13 \showbox0


The space after the closing parenthesis is indeed the same as the space after the period. This is controlled by the space factor. This is explained in more detail in Chapter 20: Spacing of Eijkhout's TeX by Topic.

The space factor can be print on the screen/.log file:

\typeout{sfcode[t]: \the\sfcodet}
\typeout{sfcode[!]: \the\sfcode!}
\typeout{sfcode[)]: \the\sfcode\)}


The space factors are:

sfcode[t]: 1000
sfcode[!]: 3000
sfcode[)]: 0


After great the space factor is 1000. The following ! increases it to 3000. The closing ), however, does not change the space factor, because its \sfcode is zero. Therefore the large space is used afterwards.

It can be fixed by \@. It is a macro that sets the space factor to 1000:

Here is some (great!)\@ text. Another word.


And \showbox confirms:

.\OT1/cmr/m/n/10 !
.\OT1/cmr/m/n/10 )
.\glue 3.33333 plus 1.66666 minus 1.11111
.\OT1/cmr/m/n/10 t


An alternative would be to change the space factor of ), e.g.:

\sfcode\)=1000


But this will not solve the problem, the parentheses could contain a whole sentence. Then the larger space would be needed:

(This is a sentence!) Another sentence follows.

-