[Tex/LaTex] Relationship of \\, \newline, \raggedright, \RaggedRight, and parindent

horizontal alignmentline-breakingragged2e

I'm trying to understand if there is anyway to get \\, when in \raggedright or \RaggedRight, to produce a new line that is not indented, while \parindent or \RaggedRightParindent are set in order to have indented paragraphs. This is necessary for certain types of text blocks (e.g., an address or a block of text with "header" info [e.g., for homework]), in which I want to set each line on its own with a hard break and no indentation. I know that people on this board strongly discourage using \\, but this seems like an appropriate use. Furthermore, as I'm exporting to Tex from markdown, via Pandoc, \\ are used for markdown line breaks (indicated by two or more spaces at the end of a line). I actually get the desired output when text is set according to memoir's default, that is, with neither \RaggedRight nor \raggedright.

So, is there any easy way to do this? I can't find anything about the relationship between \RaggedRight or \raggedright and \\ or \newline in either the ragged2e or memoir docs. My hope is to do this without other markup in the text, just adjustments in my preamble, as I write in more-or-less pure markdown and then automatically convert it to Latex. Of course, this might not be possible, but it seems so from the third example.

Here are my MWEs:

In \RaggedRight, which is my preferred way of setting text, both \\ and \newline indent the new lines (see both the header block on top and the address in the middle).

\documentclass[12pt,article,oneside]{memoir}
\usepackage{lipsum}
\usepackage{ragged2e}
\setlength{\RaggedRightParindent}{2em}
\RaggedRight
%\raggedright
%\setlength{\parindent}{2em}
\checkandfixthelayout

\begin{document}

\noindent
LastName\newline Line 2\\Line 3\\Line 4\\29 August 2014

\section{Lorem Ipsum}\label{lip}

\lipsum[1-2]

And here is my address, that I want to have set flush left with no indentation:\\
My Name\newline 7999 Any St Apt 3\\Los Angeles CA  99999\\
With more text, that also should be flowed in the paragraph, with no indentation, coming after the address. \lipsum[1]

\end{document}

\RaggedRight indentation

In \raggedright, \\, but not \newline, indents the new lines (see both the header block on top and the address in the middle).

\documentclass[12pt,article,oneside]{memoir}
\usepackage{lipsum}
\usepackage{ragged2e}
%\setlength{\RaggedRightParindent}{2em}
%\RaggedRight
\raggedright
\setlength{\parindent}{2em}
\checkandfixthelayout

\begin{document}

\noindent
LastName\newline Line 2\\Line 3\\Line 4\\29 August 2014

\section{Lorem Ipsum}\label{lip}

\lipsum[1-2]

And here is my address, that I want to have set flush left with no indentation:\\
My Name\newline 7999 Any St Apt 3\\Los Angeles CA  99999\\
With more text, that also should be flowed in the paragraph, with no indentation, coming after the address. \lipsum[1]

\end{document}

\raggedright indentation

Finally, with neither \RaggedRight nor \raggedright in place, I actually get my desired result.

\documentclass[12pt,article,oneside]{memoir}
\usepackage{lipsum}
\usepackage{ragged2e}
%\setlength{\RaggedRightParindent}{2em}
%\RaggedRight
%\raggedright
%\setlength{\parindent}{2em}
\checkandfixthelayout

\begin{document}

\noindent
LastName\newline Line 2\\Line 3\\Line 4\\29 August 2014

\section{Lorem Ipsum}\label{lip}

\lipsum[1-2]

And here is my address, that I want to have set flush left with no indentation:\\
My Name\newline 7999 Any St Apt 3\\Los Angeles CA  99999\\
With more text, that also should be flowed in the paragraph, with no indentation, coming after the address. \lipsum[1]

\end{document}

indentation with no ragged text

Best Answer

ragged2e updates both \newline and \\ to function differently. Before updating, it stores the original set of macros. The original functionality can be reinstated by placing

\makeatletter
\let\@gnewline\@raggedtwoe@saved@gnewline% Restore original functionality of \newline
\let\\\@raggedtwoe@savedcr% Restore original functionality of \\
\makeatother

in your document preamble.


Another idea is to set the contents you want flushed left as part of an unbreakable structure like a tabular. I would guess this seems sufficient as a break across the page within the address might be confusion.

enter image description here

\documentclass[12pt,article,oneside]{memoir}
\usepackage{lipsum}
\usepackage{ragged2e}
\setlength{\RaggedRightParindent}{2em}
\RaggedRight
\checkandfixthelayout

\begin{document}

\noindent
\begin{tabular}{@{}l@{}}
  LastName \\Line 2\\ Line 3\\Line 4\\29 August 2014
\end{tabular}

\section{Lorem Ipsum}

\lipsum[1-2]

And here is my address, that I want to have set flush left with no indentation: \strut

\noindent
\begin{tabular}{@{}l@{}}
  My Name\\ 7999 Any St Apt 3\\Los Angeles CA  99999
\end{tabular}

\noindent
With more text, that also should be flowed in the paragraph, with no indentation, coming after the address. \lipsum[1]

\end{document}