Reputation: 23
I want to display superscript in my pdf using r-markdown. How can i display superscripts as superscripts without changing. i'm trying to display this in latex chunk
df<- read_excel("../df.xlsx",sheet = 'sheet1' )
`r df$text`
Upvotes: 0
Views: 403
Reputation: 127
Another solution since you are using RMarkdown is to intermix HTML and utilize the <sub>
superscript tag. Just an idea if you can avoid latex.
For latex, though, I would just manually adjust the value in your latex:
i.e. change seller(1)
to seller^{(1)}
LaTeX handles superscripted superscripts and all of that stuff in a natural way. It even does the right thing when something has both a subscript and a superscript.
With @Wimpel 's answer, you can automate the process by pre-determining which values in the excel cells had superscripts at least. Still, I don't see how an XML-based Excel read would know how to convert to latex through markdown automatically.
Upvotes: 0
Reputation: 116
from what i look from your code this may help
add this piece of code in excel file where ever superscript is required
$\textsuperscript{1}$
Upvotes: 0
Reputation: 27732
Consider the following excel file superscript.xlsx
library(tidyxl)
library(tidyverse)
# Read in cells from excel
cells <- tidyxl::xlsx_cells("./data/superscript.xlsx")
# Get formatting
final <- cells %>%
# Keep relevant columns
dplyr::select(sheet, address, character, format = character_formatted) %>%
# Spread cells with mixed formatting over over multiple rows
tidyr::unnest(cols = c(format), names_sep = "_")
Now you can see what p[art of the text is formatted (with superscript), use this info in your markdown..
As you canb see above, from the content of cell A1, the 2
-part of test2
is formatted with superscript.
Upvotes: 2