[Tex/LaTex] Insert a new line without \newline command

line-breaking

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.

Best Answer

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:

MWE

\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} 
% some paragraph skip to better distinguish  lines of different paragraphs  
\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}
Related Question