当我使用考试包生成问题时,即使有特殊字符,我也可以用英语完美地做题。例如,我可以使用考试包编译的 Rnw 问题:
<<echo=FALSE, results=hide>>=
## DATA GENERATION
P <- round(runif(n = 1, min = 1000, max = 2000), digits = 2)
S <- round(runif(n = 1, min = P + 500, max = 3000), digits = 2)
## QUESTION/ANSWER GENERATION
i <- round((S - P)/P, digits = 2)*100
@
\begin{question}
Qual \'e a taxa de juros simples obtida por uma aplica\c{c}\~ao de \textdollar $\Sexpr{P}$ que, ap\'os um ano, produz um montante de \textdollar$\Sexpr{S}$?
\end{question}
\begin{solution}
Os juros s\~ao calculados por:
\begin{equation}
S = P(1+i \times n) \Rightarrow S = P + Pin \Rightarrow
\end{equation}
\begin{equation}
Pin = S - P \Rightarrow
i = \frac{S-P}{Pn} \Rightarrow i = \frac{S-P}{P}
\end{equation}
O valor absotulo dos juros \'e $\Sexpr{i}$\%.
\end{solution}
%% META-INFORMATION
%% \extype{num}
%% \exsolution{\Sexpr{fmt(abs(tstat), 3)}}
%% \exname{t statistic}
%% \extol{0.01}
例如,当我需要 ç 我只使用 \c{c} 等等。但是,我一直在尝试使用 Rmarkdown 而不是 Rnw 文件。和 Rmd 中的相同示例:
---
output: pdf_document
---
```{r data generation, echo = FALSE, results = "hide"}
P <- round(runif(n = 1, min = 1000, max = 2000), digits = 2)
S <- round(runif(n = 1, min = P + 500, max = 3000), digits = 2)
i <- round((S - P)/P, digits = 2)*100
```
Question
========
Qual é a taxa de juros simples obtida por uma aplicação de $`r P`
Solution
========
Os juros são calculados por:
\begin{equation}
S = P(1+i \times n) \Rightarrow S = P + Pin \Rightarrow
\end{equation}
\begin{equation}
Pin = S - P \Rightarrow
i = \frac{S-P}{Pn} \Rightarrow i = \frac{S-P}{P}
\end{equation}
O valor absotulo dos juros é `r i`%.
Meta-information
================
extype: num
exsolution: `r round(i, digits = 3)`
exname: Euclidean distance
extol: 0.01
我可以用 RStudio 编译,正确显示重音:
但是当我尝试时:
exams2pdf('file.Rmd', encoding = 'utf8')
它不起作用。
有人可以帮我解决这个问题吗?