Skip to content

closes #1: add a template and a skeleton for ctex documents #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 4, 2014

Conversation

yihui
Copy link
Member

@yihui yihui commented Nov 4, 2014

@yufree
Copy link
Contributor

yufree commented Nov 4, 2014

测试没问题,没想到yaml里面也可以写R代码,涨姿势了。

jjallaire added a commit that referenced this pull request Nov 4, 2014
closes #1: add a template and a skeleton for ctex documents
@jjallaire jjallaire merged commit 4c32fa6 into master Nov 4, 2014
@yihui yihui deleted the feature/ctex branch November 4, 2014 17:10
@yaatou
Copy link

yaatou commented Nov 15, 2014

你好,我想问问要是想加入日语的话可以吗

@yufree
Copy link
Contributor

yufree commented Nov 15, 2014

ctex 包里木有日文字体,不过cjk包里有个min的字体可以使用,先给个临时解决方案。你写个header里加入\usepackage{CJK} 然后写日文时把日文放到一个环境中就可以了,pdflatex编译,需要自定义字体的话就得折腾xecjk包加xelatex编译了。

\begin{CJK}{UTF8}{min}
ここは日本語だよ。
\end{CJK}

@yaatou
Copy link

yaatou commented Nov 15, 2014

谢啦 一会儿我去试试看 另外我也是刚接触这个 教授介绍安装latex 不知道日本有没有像中文这个ctex这种的安装包啊

@yufree
Copy link
Contributor

yufree commented Nov 15, 2014

额,完全不懂日语的说,应该有人动过手了。
原始latex不支持unicode,上面提及的cjk包主要是通过把字体编译成图像小框来凑合那批天天pdflatex的人;后来的xetex总算支持unicode与系统字体调用了,还向下兼容了latex,算是目前通用性最好的解决方案;另一个解决方案是luatex,如果自用可以折腾。但学术论文也大都认latex而不太感冒xetex,luatex这些后来出现的引擎,所以基于cjk的解决方案虽然老套有限制,但可以保证一句pdflatex就出东西。
如果之前没入latex的坑,建议就Rmarkdown输出网页然后另存为pdf更省心,如果真想入坑,模版什么的想看明白还得从基础控制序列学起,倒是也可以拿rstudio当latex的编辑器用,从用knitr的Rnw文档写plain tex开始上手就可以。

@yaatou
Copy link

yaatou commented Nov 15, 2014

好的谢啦,我先看看。现在已经头大了。教授很喜欢R还有latex。大力推崇。必须搞定才行。

@yihui
Copy link
Member Author

yihui commented Nov 15, 2014

如果你的教授不让你用xetex,我建议你把你的教授炒了。要是教授这么古板,以后的坑肯定还会很多。

@yaatou
Copy link

yaatou commented Nov 15, 2014

哇这么晚你在啊,有没有qq之类的即时通信的方法啊,有好多想要请教的。。

@yihui
Copy link
Member Author

yihui commented Nov 15, 2014

抱歉我很少用QQ,也不喜欢别人用即时通信工具问我问题(时间已经够碎了,经不起进一步打碎),有问题请先向全世界提问,我是指公共场所,比如论坛。我无法给所有人当客服,请谅解。

@yaatou
Copy link

yaatou commented Nov 15, 2014

sorry.我就是太着急了。谢谢你这么耐心回答我的问题。

@oliyiyi
Copy link

oliyiyi commented Jul 15, 2015

请教一下,我使用win7+texlive2015+R3.2.1+Rstudio+rmarkdown,成功运行了你这个模版文件(ctex document),如果我想修改tex文件,去哪里找中间的tex文件呢?谢谢诸位

@yufree
Copy link
Contributor

yufree commented Jul 15, 2015

@oliyiyi 下载rticles包源码,在下面路径中有个default.latex文档模版可以修改,修改后在rstudio后build and reload就可以了,如果用途专一可以考虑PR。

~/rticles/inst/rmarkdown/templates/ctex/resources

@yihui
Copy link
Member Author

yihui commented Jul 15, 2015

@oliyiyi 在这个示例文档的倒数第二节我说了模板文件在哪里。然后如果你要找从Markdown生成的.tex文件,请参见文档 http://rmarkdown.rstudio.com/pdf_document_format.html

output:
  pdf_document:
    keep_tex: true

@korterling
Copy link

遇到一个问题,中文显示正常,但Rmarkdwon却报错,
下面的绘图在R的console运行,中文正常显示
par(family='STKaiti')
plot(cars,main="测试一下",family='STKaiti',col='#FF0000')
同样上面的代码在Rmarkdwon里面缺报错
Warning in axis(side = side, at = at, labels = labels, ...): font family
'STKaiti' not found, will use 'wqy-microhei' instead

@yufree
Copy link
Contributor

yufree commented Jul 29, 2015

@yangbenfa 算不上报错 目测两个原因 一是你没有装STKaiti的字体(这字体是mac系统上的 你有文泉驿可能用的是linux内核系统) 二是最新苹果系统更新了默认字体好像叫苹方而不再使用华文系列字体

@korterling
Copy link

@yufree 是的,的确是这样的,STKaiti的字体是有的,不然在console运行代码就会报错了,结果成功显示了字体;

只是我想了解,rmd文件中为何不可指定family='STKaiti',也就是说指定也没用,而在R的console,就可以直接指定family='STKaiti',所以我想,是不是rmd支持调用系统字体就好了

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants