# Insert a new line without \newline command

I'm searching for inser a new line just push the "enter" button on the keyboard.

Is there a solution?

This is the "boring" way:

\section{mySection}
My really really really long text.\newline
A new text line.


This is instead a shorter and really less boring way:

\section{mySection}
My really really really long text.

A new text line.


And this last solution is that i adopted, but if in a really long text it will create a lots of white space on the latex editor, and this is not really nice for me.

Is there a way to create a new line just with the following code?

\section{mySection}
My really really really long text.
A new text line.

• That's going against everything TeX stands for... You may not realise it, but the fact that an EOL character in the input file doesn't result in a new line in the output file is really handy, if only for code formatting. If you really want to type your text that way, why not use a word processor instead? – jub0bs Jan 11 '14 at 11:37
• You can use \par to obtain a new paragraph. It is different from \newline or \\ which produce a line break (by the way, there is a \linebreak command, to break the line and justify the line before). – Sigur Jan 11 '14 at 13:00
• There is always \begin{verbatim} – John Kormylo Jan 11 '14 at 14:33
• I would really like to know why you need this. If you're typing regular text, you probably shouldn't be deciding where newlines go. If it's code, use verbatim. – marczellm Jan 11 '14 at 18:17

Wihouth figuring that you are trying to do exactly is hard to say, but except form small chunks of text is just a bad idea make that the end of line (EOL) equivalent to \\ or \newline.

I now that in the it is boring at first, but my suggestion anyway is learn What is the difference between \newline and \\?, \linebreak and \par (See also Downsides of using \par instead of two new lines ) and then just use blank lines to make new paragraphs (not to make new lines) and as less as possible the line breaking commands (in the end of rows of tables ... and no much more.) since probably there are better ways to obtain what you want without any \\. (I am thinking in lists, boxes with text, etc.)

Said that, in addition to obeylines environment, another options are parse lines and verbatim environments. What is better depend of what you want, because the tree environments have several significant differences, as you can compare in this example:

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\pagestyle{plain}
\usepackage{xcolor} % Some colors to distinguish environments in the compiled example
\usepackage{parselines}

% huge indentation of paragraph only for demonstration purposes.
\setlength{\parindent}{5em}
\setlength{\parskip}{.8em}

\begin{document}

This is the \texttt{document} environment.
The \LaTeX{} commands are recognized here without problems.
EOL (Linefeed and carriage return) are just ignored. But long lines are well formatted. Test: This is a long sentence to test the text wrap in a pragraph.
\\ This is a new line with \verb|\\|.
\newline This is another \verb|\newline| .
\par This is a new paragraph.

This is another paragraph. Blank lines (no matter how many) means a new paragraph, \textbf{not a new line}. Note  that a new paragraph can add indentation in the first line and vertical space, as in this example (or not, depending of \verb|\parindent| and \verb|\parskip| values.

\color{blue!50!black}
\begin{obeylines}
This is the \texttt{obeylines} environment
Some  \LaTeX{} commands can be included
This is a new line, but treated as a paragraph.
This is another line (and another paragraph).

Blank lines are just ignored.

Long lines are well formatted (as paragraphs). Test: This is a long sentence to test the text wrap in a pragraph. This is a long sentence to test the text wrap in a pragraph.

\end{obeylines}

\color{red!30!black}
\begin{parse lines}[\noindent]{#1\\}
This is the \texttt{parse lines} environment (need the \texttt{parselines} package)
Some \LaTeX{} commands can be included also (but not all).
This is a line.
This is another line.

And blank lines are just blank lines.

Long lines are well formatted (as lines): Test: This is a long sentence to test the text wrap in a pragraph. This is a long sentence to test the text wrap in a pragraph.
\end{parse lines}

\color{green!30!black}
\begin{verbatim}
This is the verbatim environment.
The \LaTeX{} command are NOT recognized here.
And use teletype text (as using \textt{})
But linefeed and carriage return are recognized.
So this is a new line

And blank lines are just blank lines.

And long lines are just long lines: Test: This is a long sentence to test the text wrap in a pragraph. This is a long sentence to test the text wrap in a pragraph.

\end{verbatim}

\end{document}


You can use \obeylines.

\documentclass{article}
\begin{document}
\bgroup\obeylines
Here line breaks
are respected.
\egroup
Here they
are not.
\end{document}


• This is pretty fantastic!! For use it in my entire document i need to put \bgroup\obeylines after \begin{document} and it's done? right? – RikyTres Jan 11 '14 at 15:44
• @RikyTres --- \obeylines stays in effect until the end of the current group, so you don't need the \bgroup and \egroup if you want it to affect the entire document. – Ian Thompson Jan 11 '14 at 16:36
• Just a warning: when \obeylines is active, table commands like hline will fail. – Carl Witthoft Jul 16 '19 at 11:33

You can easily try the following:

\\


It has the same result as

\newline

• Ok, this is another solution, but it's not what I'm searching for... – RikyTres Jan 11 '14 at 13:23
• I'm searching for a way to do a new line without any command... no \\  , no \newline and no empty line. Is there a solution like this? – RikyTres Jan 11 '14 at 13:25

I like environments, so I am going to embellish Ian Thomson's answer. I liked this idea so much, I wrote my own class in my user texmf directory that makes this code easily accessible to all of my documents:

% This code block makes it possible to process each line as #1 by defining \doline#1{#1}
\newenvironment{dolines}{\begingroup\obeylines\getlines}%
{\endgroup}
\def\marker{\end{dolines}}
{\obeylines
\gdef\getlines#1
{\def\text{#1}%
\ifx\text\marker \let\next\text
\else \doline{#1}\let\next\getlines \fi
\next}}
\def\doline#1{#1\par}


You can redefine \doline however you want. For example, to center the text:

\def\doline#1{\parskip=2mm\centering#1\par}


I use it to typeset vocabulary lists or poetry.

\begin{dolines}
My really really really long text.
A new text line.
\end{dolines}