TeX/ignorespaces
Appearance
< TeX
(Redirected from Tex\ignorespaces)< TeX
Synopsis
[edit | edit source]\ignorespaces
Description
[edit | edit source]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.
Examples
[edit | edit source]% in macro definition
\def\test#1{(#1)}
\test{a} b % Generate "(a) b" with space
\def\test#1{(#1)\ignorespaces}
\test{a} b % Generate "(a)b" without space (space ignored after a command)
% in macro invocation
\def\test{ a}
(\test)b % Generate "( a)b" with space
(\ignorespaces \test)b % Generate "(a)b" without space
% Placeholder invocations
\def\test#1{(#1)}
\test{ a}b % Generate "( a)b" with space
\def\test#1{(\ignorespaces #1)}
\test{ a}b % Generate "(a)b" without space