Removing the spaces between words

\makeatletter
\def\RemoveSpaces#1{\zap@space#1 \@empty}
\makeatother

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

\newcommand{\RemoveSpaces}[1]{%
  \begingroup
  \spaceskip=1sp
  \xspaceskip=1sp
  #1%
  \endgroup}

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:

\documentclass{article}
\usepackage[latin]{babel}
\usepackage{ragged2e}
\usepackage{lipsum}
\def\RemoveSpaces#1{%
  \begingroup
  \spaceskip1sp
  \xspaceskip1sp
  #1%
  \endgroup}

\begin{document}
\parbox{5cm}{\RaggedRight
\RemoveSpaces{\lipsum[2]}
}
\end{document}

enter image description here


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

\documentclass[english]{article}
\usepackage{babel,libertine,luacode,blindtext}
\begin{luacode*}
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 
 end 
 return List
end
\end{luacode*}
\begin{document}
\blindtext \par
\directlua{luatexbase.add_to_callback("post_linebreak_filter",rSpace,"rSpace")}
\blindtext \par

\end{document}

enter image description here

Tags:

Macros

Spacing