Thomas J. Brailey
Thomas J. Brailey

Reputation: 311

Reading and compiling .tex files into R-Markdown

Say I have the following .tex file:

\begin{table}[!htbp]
    \centering
    \setlength{\tabcolsep}{10pt}
    \renewcommand{\arraystretch}{1.5} 
    \resizebox{\textwidth}{!}{\begin{tabular}{|l|c|c|}
            \hline
            \textbf{Country}                &   \textbf{Mali}  &  \textbf{Niger}  \\ 
            \hline
            Regional Autonomy?              &   Yes            &  No              \\
            \hline
            Population (1999, millions)     &   10.6           &  10.9            \\
            \hline
            Tuareg \% of Population (2001)  &   10             &  9.3             \\
            \hline
            GDP (1999, billion USD)         &   3.4            &  2.0             \\
            \hline
            Ethnic Fractionalization (1999) &   0.8            &  0.6             \\
            \hline
            Area (million sq. km.)          &   1.2            &  1.3             \\
            \hline
            Former French Colony?           &  Yes             &  Yes             \\
            \hline 
            Political System                &  Unitary semi-presidential republic & Unitary
            semi-presidential republic  \\
            \hline
    \end{tabular}}
    \caption{Country Characteristics Around Mali's Decentralization}
\end{table}

I want to read this file into a R Markdown file such that when I compile the .Rmd file, the .tex file is rendered within the document.

Upvotes: 2

Views: 1360

Answers (1)

Gorka
Gorka

Reputation: 2079

In Rmarkdown the raw_tex extension is enabled by default. You can use the \input command to import the table as in a .tex file:

\input{table.tex}

Upvotes: 6

Related Questions