Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

r-markdown

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?

like image 995
s_om Avatar asked Jan 22 '18 04:01

s_om


1 Answers

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

enter image description here

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>
like image 196
RLesur Avatar answered Dec 06 '22 09:12

RLesur