Reputation: 1026
I want to embed a small image within the text I am writing on a Shiny html document.
I've looked around and I found this command \inlinegraphics{image.jpg}
that works in Latex. I know that to incorporate latex code in Shiny I need to include the relevant latex packages:
title: "Random document"
author: "My name"
date: "2 November 2017"
header-includes:
- \usepackage{graphicx,calc}
output: html_document
runtime: shiny
Apparently, this trick doesn't work. Any suggestions please?
Upvotes: 2
Views: 463
Reputation: 2474
One way to do this will be to create at .Rnw
document as following
\documentclass{article}
\usepackage{graphicx,calc}
\usepackage{hyperref}
\newcommand*{\inlinegraphics}[1]{%
\raisebox{-0.3\baselineskip}{%
\includegraphics[
height=\baselineskip,
width=\baselineskip,
keepaspectratio,
]{#1}%
}%
}
\begin{document}
The following will produce \inlinegraphics{images/fish.png} an image that is
within text
\end{document}
Following your suggestion, I've adapted this inline tex image post. It works fine and produces the following pdf.
However, you can't use pandoc to convert this to html (the image is dropped), and you only get the following (with no image).
<p>The following will produce <span> </span> an image that is within text</p>
Which is not so surprising since pandoc only converts a part of Latex. See tex to html post
So from what I understand, you simply want to embed directly in html. The following code is in a .Rmd
YAML document.
---
title: "Random document"
author: "My name"
date: "2 November 2017"
output: html_document
runtime: shiny
---
<p>
This is an image that I want displayed inline
<img src="images/fish.png" width="20" height="20" >
inside the text
</p>
You might want to look at this post embed image html for further details.
Upvotes: 1