how do we right align part of a line in r markdown?

浪尽此生 提交于 2019-12-05 16:56:45

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>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!