I am using a table to layout a header with one cell containing an image and another one containing a text, but I can't vertically align them properly.
Here is my code snippet:
---
output: pdf_document
---
```{r echo=FALSE}
library(knitr)
library(tibble)
header <- tibble::tibble(logo = "![](G:\\logo.png){width=50}",
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vehicula sodales ligula, at efficitur erat tincidunt ac. Aenean malesuada turpis at dui aliquam laoreet. Cras ultricies, purus vitae egestas sagittis, neque tellus rutrum purus, in pulvinar neque orci vel odio. Nulla gravida nunc nec metus cursus lacinia. Nulla et augue mattis purus faucibus eleifend. Aliquam congue eget odio vel vehicula. Vestibulum sit amet pharetra dolor. Cras gravida gravida varius. Cras suscipit lacus urna, at semper est tincidunt vel. Aliquam ipsum felis, auctor vel pulvinar vel, blandit at lorem. Ut augue ligula, suscipit non neque a, luctus ultricies lorem. Cras a sem diam.")
```
```{r echo=FALSE}
knitr::kable(header, col.names = c('', ''), align = 'c')
```
Here is the result I expected: expected_result
And here is the actual result I got: actual_result
I thought it was going to be a simple problem to solve but I can't find the solution.
Another important thing to know is that I work on a computer that does not have Internet access, I have tidyverse
at my disposal but I will not be able to install any additional packages.
Thank you very much for your help!
I agree with @Paul Lemmens.
However I tried using kable
and could not make top aligned. With the following LaTeX write up, it can be easily achieved.
---
output: pdf_document
header-includes:
- \usepackage{graphicx}
- \usepackage{lipsum}
---
\begin{figure}[h]
\centering
\begin{minipage}{0.2\textwidth}
\centering
\includegraphics[width=\textwidth]{logo.jpg} %you need to change according to image file name
\end{minipage}\hfill
\begin{minipage}{0.8\textwidth}
\lipsum[1] % This generates the text
\end{minipage}
\end{figure}