From Wikibooks, open books for an open world
< TeX
Jump to: navigation, search

< TeX




Cause TeX to ignore spaces in the input that follows immediately. This is most commonly used in macros that want to suppress spaces immediately after an invocation, as if it is a macro with no argument. However, since macro and placeholder invocation acts as if the input contains those text directly, they are also affected. See below for an example.

Randomly ignoring spaces in macros comprising a piece of running text is in general not the expectation of the user. On the other hand, in circumstances that a macro is used in special places, e.g., to define a figure or to create a LaTeX list or its item, it is sometimes useful to use \ignorespaces to allow more spaces so that the input is more readable.


\test{a} b  % Generate "(a) b" with space
\test{a} b  % Generate "(a)b" without space
% Macro invocations
\def\test{ a}
(\test)b    % Generate "( a)b" with space
(\ignorespaces \test)b % Generate "(a)b" without space
% Placeholder invocations
\test{ a}b  % Generate "( a)b" with space
\def\test#1{(\ignorespaces #1)}
\test{ a}b  % Generate "(a)b" without space