# LaTex tables in R/Rmarkdown file

#1

Hello,

I have this LaTex table from this link below:
I put it into either a R or Rmarkdown file.
It doesn't produce the result but gives squiggly red error lines that
I have to fix. How can I run the bottom LaTex code in R or Rmarkdown ?

https://www.latex-tutorial.com/tutorials/tables/

%...

\begin{table}[h!]
\begin{center}
\caption{Multirow table.}
\label{tab:table1}
\begin{tabular}{l|S|r}
\textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\
\alpha & \beta & \gamma \
\hline
\multirow{2}{}{12} & 1110.1 & a\ % <-- Combining 2 rows with arbitrary with () and content 12
& 10.1 & b\ % <-- Content of first column omitted.
\hline
3 & 23.113231 & c\
4 & 25.113231 & d\
\end{tabular}
\end{center}
\end{table}

%...

0 Likes

#2

---
title: "Untitled"
output: pdf_document
- \usepackage{caption}
- \usepackage{multirow}
---

some text

\begin{center}
\captionof{table}{Multirow Table.}
\begin{tabular}{l|l|r}
\textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3} \\
$\alpha$ & $\beta$ & $\gamma$ \\ \hline
\multirow{2}{*}{12} & 1110.1 & a \\
& 10.1 & b \\ \hline
3 & 23.113231 & c \\
4 & 25.113231 & d
\end{tabular}
\end{center}

some text


This yields the following try.pdf (73.3 KB).

0 Likes

#3

I tried it on my computer it didn’t work.
Can’t put

\usepackage{caption}
\usepackage{multirow}

where you put them.
caption and multirow are LaTeX packages. If these are not installed on your device, tinytex will install them while knitting.