\\、\newline、\raggedright、\RaggedRight 和 parindent 的关系

\\、\newline、\raggedright、\RaggedRight 和 parindent 的关系

我试图了解是否有办法\\\raggedright\RaggedRight中生成一条新线不是缩进,而\parindent或 则\RaggedRightParindent设置为缩进段落。这对于某些类型的文本块(例如,地址或带有“标题”信息的文本块[例如,用于家庭作业])是必要的,在这些文本块中,我想用硬分隔符和无缩进来设置每一行。我知道这个论坛上的人强烈反对使用\\,但这似乎是一种合适的用法。此外,当我通过 Pandoc 从 markdown 导出到 Tex 时,\\用作 markdown 换行符(用行末的两个或更多空格表示)。当根据 memoir 的默认值设置文本时,我实际上得到了所需的输出,也就是说,既不使用\RaggedRight也不使用\raggedright

那么,有没有简单的方法可以做到这一点?我在 ragged2e 或 memoir 文档中都找不到有关\RaggedRightor\raggedright\\or之间关系的任何信息\newline。我​​希望在文本中不添加其他标记的情况下做到这一点,只需在序言中进行调整,因为我或多或少用纯 markdown 编写,然后自动将其转换为 Latex。当然,这可能是不可能的,但从第三个例子来看似乎是这样的。

以下是我的 MWE:

在 中\RaggedRight,这是我设置文本的首选方式,\\和都\newline缩进新行(请参见顶部的标题块和中间的地址)。

\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 缩进

\raggedright、中\\,但不在\newline中缩进新行(请参见顶部的标题块和中间的地址)。

\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 缩进

最后,在没有\RaggedRight和的\raggedright情况下,我实际上得到了我想要的结果。

\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}

缩进且无杂乱文本

答案1

ragged2e更新\newline\\以不同的方式运行。在更新之前,它会存储原始宏集。可以通过放置

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

在您的文件序言中。


另一个想法是将您想要向左刷新的内容设置为不可破坏结构的一部分,例如tabular。我猜这似乎足够了,因为地址内的页面中断可能会造成混淆。

在此处输入图片描述

\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}

相关内容