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

Reading and compiling .tex files into 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}

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

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

\input{table.tex}