删除新行后的空格

删除新行后的空格

我需要删除在 tex 文件中以新行开始插入的空格。例如:

文件.tex:

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

文件.pdf

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

答案1

%在第一行结束后添加将取消该空格并连接两个单词paragraphthat

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

在此处输入图片描述

答案2

如果您想将其用于长段文本,您可以定义一个简单的开关,使换行符被忽略:

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

然后使用它:

\documentclass{article}

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

\begin{document}

{
\ignorelinebreaks
hello world
world hello
}

\end{document}

在此处输入图片描述

您甚至可以利用 LaTeX 的环境:

\documentclass{article}

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

\begin{document}

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

\end{document}

相关内容