【发布时间】:2019-05-16 18:27:34
【问题描述】:
我不确定我在这里是否有正确的方法,我整天都在寻找一种方法来做到这一点,没有一个文档在他们的说明中足够明确。
我想使用如下所示的模板样式:
我有 .sty 文件。我试图在我的 rmarkdown 中连接该文件,标题如下:
---
title: "title"
author: "author"
date: "`r format(Sys.time(), '%d %B, %Y')`"
mainfont: Arial
output:
pdf_document:
latex_engine: xelatex
includes:
template: analysis_orax.sty
---
但是,这并没有添加样式。如果我添加 .tex 文件,它会添加所有正文文本,这不是我想要的。
我不太喜欢使用 .tex 或 .sty;我想要的只是有一个格式很好的 .pdf 用于报告!
.sty:
\usepackage{titlesec}
\usepackage{tikz}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage[left=4cm,right=2.5cm,top=2.5cm,bottom=2cm]{geometry}
\usepackage{fancyhdr}
%------------------Main Font-------------------------
\setmainfont{Fira Sans}
%Make sure you have the compiler "XeLaTeX" activated on your settings for your LaTeX document in order to see the font
%------------------Color Set--------------------------
\definecolor{LightBlue}{RGB}{66, 163, 251}
\definecolor{DarkBlue}{RGB}{36, 100, 176}
\definecolor{LightGray}{gray}{.94}
\definecolor{DarkGray}{gray}{.172}
\definecolor{Orange}{RGB}{229, 133, 3}
\definecolor{MediumBlue}{RGB}{38, 119, 193}
%------------------Section Default Setting-------------
\titleformat*{\section}{\color{DarkBlue}\normalfont\bfseries\Huge}
\titleformat*{\subsection}{\color{LightBlue}\normalfont\bfseries\LARGE}
\titleformat*{\subsubsection}{\color{MediumBlue}\normalfont\bfseries\LARGE}
%-------------------Section Numbers Removal------------
\setcounter{secnumdepth}{0}
%-------------------------Header & Footer------------------------
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{
\begin{tikzpicture}[remember picture,overlay] \node[anchor=north west, yshift=1.5mm, xshift=-1.5mm] at (current page.north west) {\includegraphics[height=25mm]{figures/header_corner.png}};
\end{tikzpicture}
}
\fancyfoot[C]{
\begin{tikzpicture}[remember picture,overlay] \node[anchor=south east, yshift=-1.5mm, xshift=1.5mm] at (current page.south east) {\includegraphics[height=29mm]{figures/banner.png}};
\end{tikzpicture}
\textcolor{LightGray}{\thepage}
}
【问题讨论】:
-
你需要
header-includes;见,例如tex.stackexchange.com/questions/171711/… -
我已经尝试过这个建议,但没有正确的 yaml 结构:tex.stackexchange.com/questions/171711/…
标签: r latex r-markdown tex