最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

RExams change font - Stack Overflow

programmeradmin2浏览0评论

I am using R/exams via exams2nops() to generate PDFs. The font everywhere is sans serif, which I don't like. But I know that the front page must be unaltered as much as possible in order not to affect scanning afterwards.

Can I keep the first page unaltered (just change the logo, but stay in sans serif), and then change the font from page 2 onward to use LaTeX's Computer Modern Roman (text and math)? I tried to edit the original code of exams::make_nops_template(), but the best I managed is to change the font everywhere (including front page).

I am using R/exams via exams2nops() to generate PDFs. The font everywhere is sans serif, which I don't like. But I know that the front page must be unaltered as much as possible in order not to affect scanning afterwards.

Can I keep the first page unaltered (just change the logo, but stay in sans serif), and then change the font from page 2 onward to use LaTeX's Computer Modern Roman (text and math)? I tried to edit the original code of exams::make_nops_template(), but the best I managed is to change the font everywhere (including front page).

Share Improve this question edited Mar 31 at 20:13 Achim Zeileis 17.3k1 gold badge43 silver badges54 bronze badges asked Mar 31 at 3:56 Bruce JamesBruce James 2111 silver badge6 bronze badges 1
  • Does the answer below solve your problem? If so, please accept the answer by clicking the checkmark on the left (so that it is flagged accordingly here on SO). If not, please clarify the remaining problems and then we can continue to help... – Achim Zeileis Commented Apr 2 at 10:59
Add a comment  | 

1 Answer 1

Reset to default 4

Background: You don't need to alter the source code of the package or the template. It is written in such a way that the sans serif font (Helvetica) is enforced for all the elements that need to be scanned (especially exam type and exam ID). Everything else can in principle be changed - and is changed in fact by various of the supported languages.

Update: To further facilitate changing fonts, especially for the math elements, the current development version 2.4-2 of the package on R-Fe gained a new argument exams2nops(..., helvet = TRUE). If TRUE, the default, the template loads

\usepackage{helvet}
\usepackage[helvet]{sfmath}

But by setting helvet = FALSE, this is suppressed

Answer: For further modifications in the template the arguments exams2nops(..., usepackage = ..., header = ...) can be used. With usepackage you can specify a vector of character strings which are then turned into \usepackage{...} lines in the template. And header can be a character string with any LaTeX code that should be included in the header.

Example: To switch to a serif font for the exam, you can either just switch off the Helvetica font and use the default LaTeX serif font. Or you can additionally load another font such as Times New Roman via the {times} LaTeX package.

exams2nops("deriv2.Rmd", helvet = FALSE)
exams2nops("deriv2.Rmd", helvet = FALSE, usepackage = "times")

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论