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

≡放荡痞女 提交于 2019-12-07 11:22:09

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/48374906/how-do-we-right-align-part-of-a-line-in-r-markdown

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