3

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 
0

2 Answers 2

6

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.

enter image description here

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

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}

enter image description here

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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