Latex 如何从RMarkdown调用.tex中的特定代码段?

Latex 如何从RMarkdown调用.tex中的特定代码段?,latex,r-markdown,beamer,Latex,R Markdown,Beamer,我正在RMarkdown中创建演示文稿,我有以下生成图形的LaTeX代码: \begin{picturegraph}[>=triangle 45, font=\footnotesize] \node[fill,rectangle,inner sep=0pt,minimum size=5pt,label={right:{S}}] (S) at (4,2.66) {}; \node[fill,circle,inner sep=0pt,minimum size=5pt,label={below:

我正在RMarkdown中创建演示文稿,我有以下生成图形的LaTeX代码:

\begin{picturegraph}[>=triangle 45, font=\footnotesize]
\node[fill,rectangle,inner sep=0pt,minimum size=5pt,label={right:{S}}] (S) at (4,2.66) {};
\node[fill,circle,inner sep=0pt,minimum size=5pt,label={below:{X}}] (X) at (0,0) {};
\node[fill,circle,inner sep=0pt,minimum size=5pt,label={below:{Y}}] (Y) at (6,0) {};
\node[fill,circle,inner sep=0pt,minimum size=5pt,label={above:{Z}}] (Z) at (3,2) {};
\draw[->,shorten >= 1pt] (X)--(Y);
\draw[->,shorten >= 1pt] (Z)--(X);
\draw[->,shorten >= 1pt] (Z)--(Y);
\draw[->,shorten >= 1pt] (S)--(Z);
\draw[<->,dashed,shorten >= 1pt] (X) to[bend left=45] (Z);
\draw[<->,dashed,shorten >= 1pt] (X) to[bend left=30] (Y);
\end{picturegraph}
还有我的header.tex:

\definecolor{mycolorlightblue}{RGB}{103,153,200}
\definecolor{mycolordarkblue}{RGB}{0,70,127}
% remove 2nd section from header
\makeatletter
\beamer@theme@subsectionfalse
\makeatother
% change colour of lines
\setbeamercolor{separation line}{bg=mycolorlightblue}
% text title
\setbeamercolor{title}{fg=mycolordarkblue}
\setbeamercolor{frametitle}{fg=mycolordarkblue}
% text colour
\setbeamercolor{frametitle}{fg=mycolordarkblue}
% item colour
\setbeamercolor{structure}{fg=mycolordarkblue}
% no header or footer on first page
\thispagestyle{empty}
% remove title slides at beginning of sections
\AtBeginSection{}
% add page counter to the footer
\setbeamertemplate{footline}[frame number]
% logo of my university
\titlegraphic{%
  \begin{picture}(0,0)
    \put(155,0){\makebox(0,0)[rt]{\includegraphics[]{ALL-ICONS.png}}}
  \end{picture}}
几个问题:

  • picturegraph
    替换为
    tikzpicture
  • 加载丢失的
    tikz
  • 加载缺少的
    箭头
    lib
几个问题:

  • picturegraph
    替换为
    tikzpicture
  • 加载丢失的
    tikz
  • 加载缺少的
    箭头
    lib

请表示感谢。我已经用我的RMarkdown脚本更新了我的问题,谢谢。我已经用我的RMarkdown脚本和更新了我的问题。tex@DanielaRodrigues不客气!只是出于好奇:你的
图片是从哪里来的?只是我想聪明点(lol)我以为这就是那部分的名称,我不理解它是指一个包或什么的。再次感谢!抱歉,最后一个问题,您知道如何在该图形的右端创建另一个图形,而不是在下面创建吗?@DanielaRodrigues您可以使用
环境将它们并排放置。查看beamer用户指南中的一些信息example@DanielaRodrigues不客气!只是出于好奇:你的
图片是从哪里来的?只是我想聪明点(lol)我以为这就是那部分的名称,我不理解它是指一个包或什么的。再次感谢!抱歉,最后一个问题,您知道如何在该图形的右端创建另一个图形,而不是在下面创建吗?@DanielaRodrigues您可以使用
环境将它们并排放置。查看beamer用户指南中的一些示例
\definecolor{mycolorlightblue}{RGB}{103,153,200}
\definecolor{mycolordarkblue}{RGB}{0,70,127}
% remove 2nd section from header
\makeatletter
\beamer@theme@subsectionfalse
\makeatother
% change colour of lines
\setbeamercolor{separation line}{bg=mycolorlightblue}
% text title
\setbeamercolor{title}{fg=mycolordarkblue}
\setbeamercolor{frametitle}{fg=mycolordarkblue}
% text colour
\setbeamercolor{frametitle}{fg=mycolordarkblue}
% item colour
\setbeamercolor{structure}{fg=mycolordarkblue}
% no header or footer on first page
\thispagestyle{empty}
% remove title slides at beginning of sections
\AtBeginSection{}
% add page counter to the footer
\setbeamertemplate{footline}[frame number]
% logo of my university
\titlegraphic{%
  \begin{picture}(0,0)
    \put(155,0){\makebox(0,0)[rt]{\includegraphics[]{ALL-ICONS.png}}}
  \end{picture}}
---
title: |
    | ##title**

author: |
        | name
        | email
        |
        
date: "`r format(Sys.time(), '%d %B %Y')`"

output:
  beamer_presentation:
    theme: Szeged
    slide_level: 2
    includes:
      in_header: header.tex
    keep_tex: true

linkcolor: false
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```


# Outline

## Outline

1. Item 1
2. Item 2
3. Item 3

# Introduction

## First subsection

This is an example of a graph:

(I want to insert the graph here)


## Second subsection

Text

\begin{tikzpicture}[>=triangle 45, font=\footnotesize]
\node[fill,rectangle,inner sep=0pt,minimum size=5pt,label={right:{S}}] (S) at (4,2.66) {};
\node[fill,circle,inner sep=0pt,minimum size=5pt,label={below:{X}}] (X) at (0,0) {};
\node[fill,circle,inner sep=0pt,minimum size=5pt,label={below:{Y}}] (Y) at (6,0) {};
\node[fill,circle,inner sep=0pt,minimum size=5pt,label={above:{Z}}] (Z) at (3,2) {};
\draw[->,shorten >= 1pt] (X)--(Y);
\draw[->,shorten >= 1pt] (Z)--(X);
\draw[->,shorten >= 1pt] (Z)--(Y);
\draw[->,shorten >= 1pt] (S)--(Z);
\draw[<->,dashed,shorten >= 1pt] (X) to[bend left=45] (Z);
\draw[<->,dashed,shorten >= 1pt] (X) to[bend left=30] (Y);
\end{tikzpicture}
\usepackage{tikz}
\usetikzlibrary{arrows}