我们如何在 r markdown 中正确对齐一行的一部分?

Sou*_*iom 6 r r-markdown

我正在处理 R markdown 文档,并试图查看我们是否可以正确对齐句子的结尾。

句子应该是这样的:

这是同句的第一部分< spacespacespacespacespace >这是句尾。

我尝试将 LaTeX 语法与它结合使用

这是同一句话的第一部分

\begin{flushright}
sample end of sentence
\end{flushright}
Run Code Online (Sandbox Code Playgroud)

但这并没有达到预期的效果。

有人可以帮忙吗?

RLe*_*sur 6

PDF文档
使用LaTeX \hfill命令:

This is the same sentence's first part \hfill this is the end of sentence.
Run Code Online (Sandbox Code Playgroud)

HTML 文档
使用CSS float属性。
从 Pandoc 1.18 开始,您可以span使用bracketed_spans

This is the same sentence's first part [this is the end of sentence.]{style="float:right"}
Run Code Online (Sandbox Code Playgroud)

PDF和HTML?
您可以同时使用LaTeX \hfillHTML浮动跨度(小心,在\hfill和之间使用不间断空格[this):

This is the same sentence's first part \hfill [this is the end of sentence.]{style="float:right"}
Run Code Online (Sandbox Code Playgroud)

PDF结果

在此处输入图片说明

HTML 结果

This is the same sentence's first part \hfill this is the end of sentence.
Run Code Online (Sandbox Code Playgroud)