我们如何在 r markdown 中正确对齐一行的一部分? [英] how do we right align part of a line in r markdown?

查看:66
本文介绍了我们如何在 r markdown 中正确对齐一行的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

句子应该是这样的:

这是同一句话的第一部分 <spacespacespace space space> 这是句子的结尾.

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

这是同一句话的第一部分

\begin{flushright}句末样例\end{同右}

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

有人可以帮忙吗?

解决方案

PDF 文档
使用 LaTeX \hfill 命令:

这是同一个句子的第一部分 \hfill 这是句子的结尾.

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

HTML 结果

<p><strong>PDF文档</strong><br/>使用 <code>LaTeX</code><code>\hfill</code>命令:</p><p>这是同一个句子的第一部分,这是句子的结尾.</p><p><strong>HTML 文档</strong><br/>使用<code>CSS</code><code>float</code><br/>从 Pandoc 1.18 开始,您可以创建原生的 <code>span</code>与 <a href="https://pandoc.org/MANUAL.html#extension-bracketed_spans"><code>bracketed_spans</code></a></p><p>这是同一个句子的第一部分 <span style="float:right;">这是句子的结尾.</span></p><p><strong>PDF &amp;HTML?</strong><br/>您可以同时使用 <code>LaTeX</code><code>\hfill</code>和一个 <code>HTML</code>浮动跨度(小心,在 <code>\hfill</code> 和 <code>[this</code>)之间使用不间断空格:</p><p>这是同一个句子的第一部分 <span style="float:right;">这是句子的结尾.</span></p>

I am working on an R markdown document and was trying to see if we can right align the end of a sentence.

The sentence should look like :

This is the same sentence's first part <spacespacespace space space> this is the end of sentence.

I have tried comibining LaTeX syntax with it

This is the same sentence's first part

\begin{flushright}
sample end of sentence
\end{flushright}

But this doesnt give the desired effect.

Can someone please help?

解决方案

PDF document
Use LaTeX \hfill command:

This is the same sentence's first part \hfill this is the end of sentence.

HTML document
Use CSS float property.
Since Pandoc 1.18, you can create a native span with bracketed_spans

This is the same sentence's first part [this is the end of sentence.]{style="float:right"}

Both PDF & HTML?
You can use both LaTeX \hfill and a HTML floating span (be careful, use a no-break-space between \hfill and [this):

This is the same sentence's first part \hfill [this is the end of sentence.]{style="float:right"}


PDF result

HTML result

<p><strong>PDF document</strong><br />
Use <code>LaTeX</code> <code>\hfill</code> command:</p>
<p>This is the same sentence’s first part this is the end of sentence.</p>
<p><strong>HTML document</strong><br />
Use <code>CSS</code> <code>float</code> property.<br />
Since Pandoc 1.18, you can create a native <code>span</code> with <a href="https://pandoc.org/MANUAL.html#extension-bracketed_spans"><code>bracketed_spans</code></a></p>
<p>This is the same sentence’s first part <span style="float:right;">this is the end of sentence.</span></p>
<p><strong>Both PDF &amp; HTML?</strong><br />
You can use both <code>LaTeX</code> <code>\hfill</code> and a <code>HTML</code> floating span (be careful, use a no-break-space between <code>\hfill</code> and <code>[this</code>):</p>
<p>This is the same sentence’s first part  <span style="float:right;">this is the end of sentence.</span></p>

这篇关于我们如何在 r markdown 中正确对齐一行的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆