# Remove space after new line

I need to remove the space inserted by starting a new line in tex file. Exmple:

file.tex:

This is actually a paragraph
that will continue to this new line.


file.pdf

This is actually a paragraph that will continue to this new line.
^
I would like to remove this space


Adding a % after the end of the first line will cancel that space and join the two words paragraph and that.

This is actually a paragraph% <--- This will suppress the spacing
that will continue to this new line.


• This is most likely a duplicate. Aug 24, 2018 at 12:36
• Being a very basic question, I guess very likely yes, but I can't find one. Aug 24, 2018 at 12:41

If you want to use this for a long piece of text you could define a simple switch that makes new line characters be ignored:

\def\ignorelinebreaks{%
\catcode\^^M=9
\endlinechar=\^^M}


then use it with:

\documentclass{article}

\def\ignorelinebreaks{%
\catcode\^^M=9
\endlinechar=\^^M}

\begin{document}

{
\ignorelinebreaks
hello world
world hello
}

\end{document}


You can even exploit LaTeX's environments:

\documentclass{article}

\def\ignorelinebreaks{%
\catcode\^^M=9
\endlinechar=\^^M}

\begin{document}

\begin{ignorelinebreaks}
hello world
world hello
\end{ignorelinebreaks}

\end{document}