TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to remove spaces from in between the words in a text? Something like

\RemoveSpaces{This is   my    sentence.}

which will be converted to


share|improve this question
Why would you want to do this? – User 17670 Mar 6 '13 at 15:48
As a deterrent against copy and pasting the real text from the resulting searchable PDF file. – Reza Mar 6 '13 at 20:18
up vote 44 down vote accepted
\def\RemoveSpaces#1{\zap@space#1 \@empty}
share|improve this answer
I didn't believe it, but ... it works! – yo' Dec 18 '12 at 14:53

A different approach, that ensures correct hyphenation and line breaks between words is


This reduces the interword space to the minimum possible positive value (that's not visible to the human eye), but still paragraphs will be built as usual. Complete example:



enter image description here

share|improve this answer

a solution with lualatex for all spaces between words in a paragraph. Kerning and discretionaries are not affected.

function rSpace(List)
 for line in node.traverse_id(0,List) do -- go through all lines
   for s in node.traverse_id(10,line.head) do node.remove(line.head,s) end 
 return List
\blindtext \par
\blindtext \par


enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.