读取 .tex 文件并将其编译为 R-Markdown

Tho*_*ley 2 tex r-markdown

假设我有以下 .tex 文件:

\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}
Run Code Online (Sandbox Code Playgroud)

我想将此文件读入 R Markdown 文件,以便在编译 .Rmd 文件时,.tex 文件会在文档中呈现。

Gor*_*rka 6

在 Rmarkdown 中,raw_tex默认情况下启用该扩展。您可以使用以下\input命令将表导入到.tex文件中:

\input{table.tex}
Run Code Online (Sandbox Code Playgroud)